[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Jul 6 16:11:14 CDT 2011


branch "master" has been updated
       via  81d6eb6688d12416f6761ac9eef9d488f5001622 (commit)
      from  0de3a6da08326394ca81228ee1c0ae770f78dbcb (commit)

Summary of changes:
 test/WorkQueue/TestWorkQueue.cpp |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit 81d6eb6688d12416f6761ac9eef9d488f5001622
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 6 16:11:19 2011 -0500

    Fix race condition in work queue test.

diff --git a/test/WorkQueue/TestWorkQueue.cpp b/test/WorkQueue/TestWorkQueue.cpp
index 4bab4fa..099445f 100644
--- a/test/WorkQueue/TestWorkQueue.cpp
+++ b/test/WorkQueue/TestWorkQueue.cpp
@@ -82,15 +82,21 @@ public:
         : mStarted(false), mStopped(false) { }
     void start()
     {
+        boost::unique_lock<boost::mutex> lock(mLock);
         mStarted = true;
+        mCond.notify_one();
     }
     void stop()
     {
+        boost::unique_lock<boost::mutex> lock(mLock);
         mStopped = true;
+        mCond.notify_one();
     }
 
     bool mStarted;
     bool mStopped;
+    boost::mutex mLock;
+    boost::condition_variable mCond;
 };
 
 typedef IceUtil::Handle<ThreadHook> ThreadHookPtr;
@@ -447,6 +453,13 @@ BOOST_AUTO_TEST_CASE(defaultListener)
     NotifyTaskPtr work4(new NotifyTask);
     WorkSeq works;
 
+    {
+        boost::unique_lock<boost::mutex> lock(tHook->mLock);
+        while (!tHook->mStarted)
+        {
+            tHook->mCond.wait(lock);
+        }
+    }
     BOOST_CHECK(tHook->mStarted == true);
     BOOST_CHECK(tHook->mStopped == false);
 
@@ -478,6 +491,13 @@ BOOST_AUTO_TEST_CASE(defaultListener)
 
     queue->shutdown();
 
+    {
+        boost::unique_lock<boost::mutex> lock(tHook->mLock);
+        while (!tHook->mStopped)
+        {
+            tHook->mCond.wait(lock);
+        }
+    }
     BOOST_CHECK(tHook->mStopped == true);
 }
 

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list