summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-11-06 10:47:57 +0000
committerGordon Sim <gsim@apache.org>2008-11-06 10:47:57 +0000
commit8083badb0a20b9c80797437e39cb9ed5c79f2edb (patch)
tree21aa368b4fda3cee47badc40ca9208c18387b59c /qpid/cpp/src
parentf04d8a5bdde4c141f6d8ad04149e8c757fedf49a (diff)
downloadqpid-python-8083badb0a20b9c80797437e39cb9ed5c79f2edb.tar.gz
SubscriptionManager and Dispatcher were missing wait() methods meaning that if start was called there was no way to join with the dispatch thread and shutdown cleanly. Fixed by adding that method.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711838 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/client/Dispatcher.cpp5
-rw-r--r--qpid/cpp/src/qpid/client/Dispatcher.h1
-rw-r--r--qpid/cpp/src/qpid/client/SubscriptionManager.cpp5
-rw-r--r--qpid/cpp/src/qpid/client/SubscriptionManager.h5
-rw-r--r--qpid/cpp/src/tests/ClientSessionTest.cpp4
5 files changed, 18 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/client/Dispatcher.cpp b/qpid/cpp/src/qpid/client/Dispatcher.cpp
index da6607fb9e..59bc265bd2 100644
--- a/qpid/cpp/src/qpid/client/Dispatcher.cpp
+++ b/qpid/cpp/src/qpid/client/Dispatcher.cpp
@@ -54,6 +54,11 @@ void Dispatcher::start()
worker = Thread(this);
}
+void Dispatcher::wait()
+{
+ worker.join();
+}
+
void Dispatcher::run()
{
Mutex::ScopedLock l(lock);
diff --git a/qpid/cpp/src/qpid/client/Dispatcher.h b/qpid/cpp/src/qpid/client/Dispatcher.h
index 921c6449a3..e84f8f303d 100644
--- a/qpid/cpp/src/qpid/client/Dispatcher.h
+++ b/qpid/cpp/src/qpid/client/Dispatcher.h
@@ -63,6 +63,7 @@ public:
Dispatcher(const Session& session, const std::string& queue = "");
void start();
+ void wait();
void run();
void stop();
void setAutoStop(bool b);
diff --git a/qpid/cpp/src/qpid/client/SubscriptionManager.cpp b/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
index 7445202ec3..c91ae178ac 100644
--- a/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
+++ b/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
@@ -92,6 +92,11 @@ void SubscriptionManager::start()
dispatcher.start();
}
+void SubscriptionManager::wait()
+{
+ dispatcher.wait();
+}
+
void SubscriptionManager::stop()
{
dispatcher.stop();
diff --git a/qpid/cpp/src/qpid/client/SubscriptionManager.h b/qpid/cpp/src/qpid/client/SubscriptionManager.h
index 58d880fa83..948126e271 100644
--- a/qpid/cpp/src/qpid/client/SubscriptionManager.h
+++ b/qpid/cpp/src/qpid/client/SubscriptionManager.h
@@ -210,6 +210,11 @@ class SubscriptionManager : public sys::Runnable
* @see start
*/
void start();
+
+ /**
+ * Wait for the thread started by a call to start() to complete.
+ */
+ void wait();
/** If set true, run() will stop when all subscriptions
* are cancelled. If false, run will only stop when stop()
diff --git a/qpid/cpp/src/tests/ClientSessionTest.cpp b/qpid/cpp/src/tests/ClientSessionTest.cpp
index cca16bd9f8..43c12ddf5c 100644
--- a/qpid/cpp/src/tests/ClientSessionTest.cpp
+++ b/qpid/cpp/src/tests/ClientSessionTest.cpp
@@ -306,7 +306,7 @@ QPID_AUTO_TEST_CASE(testRelease) {
}
fix.subs.setAutoStop(false);
- sys::Thread runner(fix.subs);//start dispatcher thread
+ fix.subs.start();
SubscriptionSettings settings;
settings.autoAck = 0;
@@ -330,7 +330,7 @@ QPID_AUTO_TEST_CASE(testRelease) {
}
fix.subs.stop();
- runner.join();
+ fix.subs.wait();
fix.session.close();
}