From 233cc9184c758702d8fa4a83d1bf8ec7dc0b3474 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 26 Jul 2007 15:47:23 +0000 Subject: * 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 --- cpp/src/tests/Cluster.h | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'cpp/src/tests/Cluster.h') 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 #include #include -#include #include /** @@ -48,26 +45,12 @@ using namespace boost; void null_deleter(void*) {} template -class TestHandler : public Handler, public vector +class TestHandler : public Handler, public ConcurrentQueue { - 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("<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::waitPop; }; typedef TestHandler 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(), bind(&Cluster::size,this), n)); + return wait(boost::bind( + equal_to(), bind(&Cluster::size,this), n)); } TestSessionFrameHandler received; -- cgit v1.2.1