summaryrefslogtreecommitdiff
path: root/cpp/src/tests/Cluster.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/tests/Cluster.h')
-rw-r--r--cpp/src/tests/Cluster.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpp/src/tests/Cluster.h b/cpp/src/tests/Cluster.h
index bf6d1c2a64..c2909e0c1b 100644
--- a/cpp/src/tests/Cluster.h
+++ b/cpp/src/tests/Cluster.h
@@ -48,20 +48,25 @@ using namespace boost;
void null_deleter(void*) {}
template <class T>
-struct TestHandler : public Handler<T&>, public vector<T>, public Monitor
+class TestHandler : public Handler<T&>, public vector<T>
{
+ Monitor lock;
+
+ public:
void handle(T& frame) {
- Mutex::ScopedLock l(*this);
+ Mutex::ScopedLock l(lock);
push_back(frame);
- notifyAll();
+ BOOST_MESSAGE(getpid()<<" TestHandler::handle: " << this->size());
+ lock.notifyAll();
}
bool waitFor(size_t n) {
- Mutex::ScopedLock l(*this);
- AbsTime deadline(now(), 5*TIME_SEC);
- while (vector<T>::size() != n && wait(deadline))
+ Mutex::ScopedLock l(lock);
+ BOOST_MESSAGE(getpid()<<" TestHandler::waitFor("<<n<<") "<<this->size());
+ AbsTime deadline(now(), 2*TIME_SEC);
+ while (vector<T>::size() < n && lock.wait(deadline))
;
- return vector<T>::size() == n;
+ return vector<T>::size() >= n;
}
};