You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/11/06 11:48:04 UTC

svn commit: r711838 - in /incubator/qpid/trunk/qpid/cpp/src: qpid/client/Dispatcher.cpp qpid/client/Dispatcher.h qpid/client/SubscriptionManager.cpp qpid/client/SubscriptionManager.h tests/ClientSessionTest.cpp

Author: gsim
Date: Thu Nov  6 02:47:57 2008
New Revision: 711838

URL: http://svn.apache.org/viewvc?rev=711838&view=rev
Log:
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.


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.h
    incubator/qpid/trunk/qpid/cpp/src/tests/ClientSessionTest.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.cpp?rev=711838&r1=711837&r2=711838&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.cpp Thu Nov  6 02:47:57 2008
@@ -54,6 +54,11 @@
     worker = Thread(this);
 }
 
+void Dispatcher::wait()
+{
+    worker.join();
+}
+
 void Dispatcher::run()
 {
     Mutex::ScopedLock l(lock);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.h?rev=711838&r1=711837&r2=711838&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/Dispatcher.h Thu Nov  6 02:47:57 2008
@@ -63,6 +63,7 @@
     Dispatcher(const Session& session, const std::string& queue = "");
 
     void start();
+    void wait();
     void run();
     void stop();
     void setAutoStop(bool b);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.cpp?rev=711838&r1=711837&r2=711838&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.cpp Thu Nov  6 02:47:57 2008
@@ -92,6 +92,11 @@
     dispatcher.start();
 }
 
+void SubscriptionManager::wait()
+{
+    dispatcher.wait();
+}
+
 void SubscriptionManager::stop()
 {
     dispatcher.stop();

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.h?rev=711838&r1=711837&r2=711838&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/SubscriptionManager.h Thu Nov  6 02:47:57 2008
@@ -210,6 +210,11 @@
      * @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()

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/ClientSessionTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/ClientSessionTest.cpp?rev=711838&r1=711837&r2=711838&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/ClientSessionTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/ClientSessionTest.cpp Thu Nov  6 02:47:57 2008
@@ -306,7 +306,7 @@
     }
 
     fix.subs.setAutoStop(false);
-    sys::Thread runner(fix.subs);//start dispatcher thread
+    fix.subs.start();
     SubscriptionSettings settings;
     settings.autoAck = 0;
 
@@ -330,7 +330,7 @@
     }
     
     fix.subs.stop();
-    runner.join();
+    fix.subs.wait();
     fix.session.close();
 }