Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F402D641 for ; Mon, 30 Jul 2012 13:43:35 +0000 (UTC) Received: (qmail 52106 invoked by uid 500); 30 Jul 2012 13:43:35 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 52067 invoked by uid 500); 30 Jul 2012 13:43:35 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 52060 invoked by uid 99); 30 Jul 2012 13:43:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jul 2012 13:43:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jul 2012 13:43:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2FB1A238897A for ; Mon, 30 Jul 2012 13:42:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120730134245.2FB1A238897A@eris.apache.org> 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."); }