[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
Thu Jun 28 10:31:33 CDT 2012


branch "master" has been updated
       via  298cd37ffa93d18a5f0e7284de057c8d024ee297 (commit)
       via  09f61426008844f791481372becfe8b2798ab467 (commit)
       via  dd106821624a7b45b6011c8e8ffa37d137c83892 (commit)
      from  d5f4d6788c674292b7c5a01895d6ef9536ab70dc (commit)

Summary of changes:
 include/AsteriskSCF/Operations/OperationMonitor.h |    8 ++++++++
 src/ThreadPool/ThreadPool.cpp                     |    8 ++++++++
 src/ThreadPool/WorkerThread.cpp                   |   19 +++++++++++++------
 3 files changed, 29 insertions(+), 6 deletions(-)


- Log -----------------------------------------------------------------
commit 298cd37ffa93d18a5f0e7284de057c8d024ee297
Merge: 09f6142 dd10682
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jun 28 13:00:24 2012 -0230

    Merge branch 'alternate_thread_cleanup'


commit 09f61426008844f791481372becfe8b2798ab467
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jun 28 12:59:25 2012 -0230

    Clear cached AMD callbacks as soon as possible.

diff --git a/include/AsteriskSCF/Operations/OperationMonitor.h b/include/AsteriskSCF/Operations/OperationMonitor.h
index 968f910..9e11b79 100644
--- a/include/AsteriskSCF/Operations/OperationMonitor.h
+++ b/include/AsteriskSCF/Operations/OperationMonitor.h
@@ -498,6 +498,10 @@ private:
         {
             (*iter)->ice_response(ContextResultData<RT>::mResult);
         }
+        //
+        // Force the issue that these callbacks will never be reused.
+        //
+        mCallbacks.clear();
     }
 
     void onSetException()
@@ -507,6 +511,10 @@ private:
         {
             (*iter)->ice_exception(*(mExceptionResult->exception()));
         }
+        //
+        // Force the issue that these callbacks will never be reused.
+        //
+        mCallbacks.clear();
     }
     CB mAMDProxy;
     std::vector<CB> mCallbacks;

commit dd106821624a7b45b6011c8e8ffa37d137c83892
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Jun 27 16:27:46 2012 -0230

    Move thread cleanup out of the WorkerThread destructor and have the thread pool mark the worker thread as dead explicitly from the killThreads method.

diff --git a/src/ThreadPool/ThreadPool.cpp b/src/ThreadPool/ThreadPool.cpp
index 44ce0df..005bd27 100644
--- a/src/ThreadPool/ThreadPool.cpp
+++ b/src/ThreadPool/ThreadPool.cpp
@@ -101,6 +101,14 @@ public:
     void killThreads(ThreadContainer& container,
             ThreadIterator first, ThreadIterator last)
     {
+        for(ThreadIterator iter = first; iter != last; ++iter)
+        {
+            //
+            // It is important to tell the worker thread that it is done
+            // here so we can avoid unnecessary mishaps!
+            //
+            (*iter)->setState(Dead);
+        }
         container.erase(first, last);
     }
 
diff --git a/src/ThreadPool/WorkerThread.cpp b/src/ThreadPool/WorkerThread.cpp
index d8a68b8..8890785 100644
--- a/src/ThreadPool/WorkerThread.cpp
+++ b/src/ThreadPool/WorkerThread.cpp
@@ -101,16 +101,23 @@ WorkerThread::WorkerThread(const QueuePtr& workQueue, WorkerThreadListener *list
 
 WorkerThread::~WorkerThread()
 {
-    setState(Dead);
-    mPriv->mThread.join();
+    //
+    // We can't do stuff with the worker thread here!
+    //
 }
 
 void WorkerThread::setState(ThreadState newState)
 {
-    boost::unique_lock<boost::mutex> lock(mPriv->mLock);
-    mPriv->mState = newState;
-    mPriv->mWakeUp = true;
-    mPriv->mCond.notify_one();
+    {
+        boost::lock_guard<boost::mutex> lock(mPriv->mLock);
+        mPriv->mState = newState;
+        mPriv->mWakeUp = true;
+        mPriv->mCond.notify_one();
+    }
+    if (newState == Dead)
+    {
+        mPriv->mThread.join();
+    }
 }
 
 bool WorkerThread::operator==(const WorkerThread& rhs)

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


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



More information about the asterisk-scf-commits mailing list