activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1367087 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
Date Mon, 30 Jul 2012 13:42:45 GMT
Author: tabish
Date: Mon Jul 30 13:42:44 2012
New Revision: 1367087

URL: http://svn.apache.org/viewvc?rev=1367087&view=rev
Log:
Ensure the lock on the worker queue always get released. 

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp?rev=1367087&r1=1367086&r2=1367087&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/ThreadPoolExecutor.cpp
Mon Jul 30 13:42:44 2012
@@ -413,12 +413,12 @@ namespace concurrent{
             try {
                 // Remove rare and surprising possibility of
                 // isTerminated() && getPoolSize() > 0
+                mainLock.unlock();
                 return runStateAtLeast(ctl.get(), TIDYING) ? 0 : workers.size();
             } catch(Exception& ex) {
                 mainLock.unlock();
                 throw;
             }
-            mainLock.unlock();
         }
 
         int getActiveCount() {
@@ -432,23 +432,23 @@ namespace concurrent{
                         ++n;
                     }
                 }
+                mainLock.unlock();
                 return n;
             } catch(Exception& ex) {
                 mainLock.unlock();
                 throw;
             }
-            mainLock.unlock();
         }
 
         int getLargestPoolSize() {
             mainLock.lock();
             try {
+                mainLock.unlock();
                 return largestPoolSize;
             } catch(Exception& ex) {
                 mainLock.unlock();
                 throw;
             }
-            mainLock.unlock();
         }
 
         long long getTaskCount() {
@@ -463,12 +463,13 @@ namespace concurrent{
                         ++n;
                     }
                 }
+
+                mainLock.unlock();
                 return n + workQueue->size();
             } catch(Exception& ex) {
                 mainLock.unlock();
                 throw;
             }
-            mainLock.unlock();
         }
 
         long long getCompletedTaskCount() {
@@ -480,12 +481,13 @@ namespace concurrent{
                     Worker* worker = iter->next();
                     n += worker->completedTasks;
                 }
+
+                mainLock.unlock();
                 return n;
             } catch(Exception& ex) {
                 mainLock.unlock();
                 throw;
             }
-            mainLock.unlock();
         }
 
         /**
@@ -843,6 +845,7 @@ namespace concurrent{
                 throw;
             }
             mainLock.unlock();
+            return false;
         }
 
         bool awaitTermination(long long timeout, const TimeUnit& unit) {
@@ -870,6 +873,7 @@ namespace concurrent{
                 throw;
             }
             mainLock.unlock();
+            return false;
         }
 
         void setCorePoolSize(int corePoolSize) {
@@ -1114,6 +1118,7 @@ namespace concurrent{
                 if (t == NULL || (rs >= SHUTDOWN && !(rs == SHUTDOWN &&
firstTask == NULL))) {
                     decrementWorkerCount();
                     tryTerminate();
+                    mainLock.unlock();
                     return false;
                 }
 
@@ -1255,6 +1260,8 @@ namespace concurrent{
                     timedOut = false;
                 }
             }
+
+            return NULL;
         }
 
         /**
@@ -1305,7 +1312,7 @@ ThreadPoolExecutor::ThreadPoolExecutor(i
 
     try{
 
-        if(workQueue == NULL) {
+        if (workQueue == NULL) {
             throw NullPointerException(__FILE__, __LINE__, "The BlockingQueue pointer cannot
be NULL.");
         }
 



Mime
View raw message