diff options
| author | Alan Conway <aconway@apache.org> | 2007-07-26 15:47:23 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-07-26 15:47:23 +0000 |
| commit | 233cc9184c758702d8fa4a83d1bf8ec7dc0b3474 (patch) | |
| tree | 6a73a6dfb117218e8fd94c8b447def68e0ab9de0 /cpp/src/tests/Cluster.h | |
| parent | 89a8765ee2bac1d77be65f1011ffeeb2cbbabe2d (diff) | |
| download | qpid-python-233cc9184c758702d8fa4a83d1bf8ec7dc0b3474.tar.gz | |
* README: Instructions for openais install.
* configure.ac: Enable clustering if suitable openais is present.
* src/tests/Cluster.cpp, .h, Cluster_child: Updated for 0-10
* src/qpid/sys/ConcurrentQueue.h: Added waitPop()
* src/Makefile.am, src/qpid/sys/ThreadSafeQueue.h, ProducerConsumer.h:
Removed unused code, ConcurrentQueue provides same functionality.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@559859 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/Cluster.h')
| -rw-r--r-- | cpp/src/tests/Cluster.h | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/cpp/src/tests/Cluster.h b/cpp/src/tests/Cluster.h index e896fccafe..02e642f641 100644 --- a/cpp/src/tests/Cluster.h +++ b/cpp/src/tests/Cluster.h @@ -20,16 +20,13 @@ */ #include "qpid/cluster/Cluster.h" +#include "qpid/sys/ConcurrentQueue.h" #include "qpid/framing/AMQFrame.h" -#include "qpid/framing/ChannelOkBody.h" -#include "qpid/framing/BasicGetOkBody.h" -#include "qpid/log/Logger.h" #include <boost/bind.hpp> #include <boost/test/test_tools.hpp> #include <iostream> -#include <vector> #include <functional> /** @@ -48,26 +45,12 @@ using namespace boost; void null_deleter(void*) {} template <class T> -class TestHandler : public Handler<T&>, public vector<T> +class TestHandler : public Handler<T&>, public ConcurrentQueue<T> { - Monitor lock; - public: - void handle(T& frame) { - Mutex::ScopedLock l(lock); - push_back(frame); - BOOST_MESSAGE(getpid()<<" TestHandler::handle: " << this->size()); - lock.notifyAll(); - } - - bool waitFor(size_t n) { - Mutex::ScopedLock l(lock); - BOOST_MESSAGE(getpid()<<" TestHandler::waitFor("<<n<<") "<<this->size()); - AbsTime deadline(now(), 2*TIME_SEC); - while (this->size() < n && lock.wait(deadline)) - ; - return this->size() >= n; - } + void handle(T& frame) { push(frame); } + bool waitPop(T& x) { return waitPop(x, TIME_SEC); } + using ConcurrentQueue<T>::waitPop; }; typedef TestHandler<AMQFrame> TestFrameHandler; @@ -83,7 +66,8 @@ struct TestCluster : public Cluster /** Wait for cluster to be of size n. */ bool waitFor(size_t n) { BOOST_CHECKPOINT("About to call Cluster::wait"); - return wait(boost::bind(equal_to<size_t>(), bind(&Cluster::size,this), n)); + return wait(boost::bind( + equal_to<size_t>(), bind(&Cluster::size,this), n)); } TestSessionFrameHandler received; |
