Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 10074 invoked from network); 20 Sep 2009 17:49:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Sep 2009 17:49:12 -0000 Received: (qmail 33078 invoked by uid 500); 20 Sep 2009 17:49:12 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 33023 invoked by uid 500); 20 Sep 2009 17:49:12 -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 33014 invoked by uid 99); 20 Sep 2009 17:49:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Sep 2009 17:49:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Sun, 20 Sep 2009 17:49:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2A32D238889D; Sun, 20 Sep 2009 17:48:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r817063 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks: Condition.h Lock.h Date: Sun, 20 Sep 2009 17:48:50 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090920174850.2A32D238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sun Sep 20 17:48:49 2009 New Revision: 817063 URL: http://svn.apache.org/viewvc?rev=817063&view=rev Log: Add more well defined API around exceptions specification. Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h?rev=817063&r1=817062&r2=817063&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Condition.h Sun Sep 20 17:48:49 2009 @@ -20,6 +20,7 @@ #include +#include #include #include @@ -132,8 +133,8 @@ virtual ~Condition() {} /** - * Causes the current thread to wait until it is signalled or interrupted. - *

+ * Causes the current thread to wait until it is signaled or interrupted. + * * The lock associated with this Condition is atomically released and the current * thread becomes disabled for thread scheduling purposes and lies dormant until one * of four things happens: @@ -169,6 +170,9 @@ * in response to a signal. In that case the implementation must ensure that the * signal is redirected to another waiting thread, if there is one. * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. + * * @throws InterruptedException * if the current thread is interrupted (and interruption of thread * suspension is supported) @@ -177,12 +181,13 @@ * if the caller is not the lock owner. */ virtual void await() - throw( decaf::lang::exceptions::InterruptedException, + throw( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException, decaf::lang::exceptions::IllegalMonitorStateException ) = 0; /** * Causes the current thread to wait until it is signalled. - *

+ * * The lock associated with this condition is atomically released and the current * thread becomes disabled for thread scheduling purposes and lies dormant until * one of three things happens: @@ -208,16 +213,20 @@ * (such as IllegalMonitorStateException) and the implementation must document * that fact. * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. + * * @throws IllegalMonitorStateException * if the caller is not the lock owner. */ virtual void awaitUninterruptibly() - throw( decaf::lang::exceptions::IllegalMonitorStateException ) = 0; + throw( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::IllegalMonitorStateException ) = 0; /** - * Causes the current thread to wait until it is signalled or interrupted, or + * Causes the current thread to wait until it is signaled or interrupted, or * the specified waiting time elapses. - *

+ * * The lock associated with this condition is atomically released and the current * thread becomes disabled for thread scheduling purposes and lies dormant until * one of five things happens: @@ -284,6 +293,9 @@ * a subsequent call to this method to finish waiting out the desired time. * A value less than or equal to zero indicates that no time remains. * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. + * * @throws InterruptedException * if the current thread is interrupted (and interruption of thread suspension * is supported) @@ -292,11 +304,12 @@ * if the caller is not the lock owner. */ virtual long long awaitNanos( long long nanosTimeout ) - throw( decaf::lang::exceptions::InterruptedException, + throw( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException, decaf::lang::exceptions::IllegalMonitorStateException ) = 0; /** - * Causes the current thread to wait until it is signalled or interrupted, or the + * Causes the current thread to wait until it is signaled or interrupted, or the * specified waiting time elapses. This method is behaviorally equivalent to: * * awaitNanos(unit.toNanos(time)) > 0 @@ -307,6 +320,9 @@ * @returns false if the waiting time detectably elapsed before return from the * method, else true * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. + * * @throws InterruptedException * if the current thread is interrupted (and interruption of thread suspension * is supported) @@ -315,13 +331,14 @@ * if the caller is not the lock owner. */ virtual bool await( long long time, const TimeUnit& unit ) - throw( decaf::lang::exceptions::InterruptedException, + throw( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException, decaf::lang::exceptions::IllegalMonitorStateException ) = 0; /* - * Causes the current thread to wait until it is signalled or interrupted, or the + * Causes the current thread to wait until it is signaled or interrupted, or the * specified deadline elapses. - *

+ * * The lock associated with this condition is atomically released and the current * thread becomes disabled for thread scheduling purposes and lies dormant until one * of five things happens: @@ -377,6 +394,9 @@ * * @returns false if the deadline has elapsed upon return, else true * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. + * * @throws InterruptedException * if the current thread is interrupted (and interruption of thread suspension * is supported) @@ -384,25 +404,32 @@ * @throws IllegalMonitorStateException * if the caller is not the lock owner. */ -// virtual bool awaitUntil( Date deadline ) -// throw( decaf::lang::exceptions::InterruptedException, -// decaf::lang::exceptions::IllegalMonitorStateException ) = 0; + virtual bool awaitUntil( const Date& deadline ) + throw( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException, + decaf::lang::exceptions::IllegalMonitorStateException ) = 0; /** * Wakes up one waiting thread. - *

+ * * If any threads are waiting on this condition then one is selected for waking up. * That thread must then re-acquire the lock before returning from await. + * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. */ - virtual void signal() = 0; + virtual void signal() throw ( decaf::lang::exceptions::RuntimeException ) = 0; /** * Wakes up all waiting threads. - *

+ * * If any threads are waiting on this condition then they are all woken up. Each * thread must re-acquire the lock before it can return from await. + * + * @throws RuntimeException + * if an unexpected error occurs while trying to wait on the Condition. */ - virtual void signalAll() = 0; + virtual void signalAll() throw ( decaf::lang::exceptions::RuntimeException ) = 0; }; Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h?rev=817063&r1=817062&r2=817063&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/Lock.h Sun Sep 20 17:48:49 2009 @@ -103,18 +103,19 @@ /** * Acquires the lock. - *

+ * * If the lock is not available then the current thread becomes disabled for thread * scheduling purposes and lies dormant until the lock has been acquired. - *

+ * * Implementation Considerations - *

+ * * A Lock implementation may be able to detect erroneous use of the lock, such as an - * invocation that would cause deadlock, and may throw an (unchecked) exception in - * such circumstances. The circumstances and the exception type must be documented - * by that Lock implementation. + * invocation that would cause deadlock, and may throw an exception in such circumstances. + * The circumstances and the exception type must be documented by that Lock implementation. + * + * @throws RuntimeException if an error occurs while acquiring the lock. */ - virtual void lock() = 0; + virtual void lock() throw( decaf::lang::exceptions::RuntimeException ) = 0; /** * Acquires the lock unless the current thread is interrupted. @@ -147,15 +148,17 @@ * An implementation can favor responding to an interrupt over normal method return. * * A Lock implementation may be able to detect erroneous use of the lock, such as an - * invocation that would cause deadlock, and may throw an (unchecked) exception in - * such circumstances. The circumstances and the exception type must be documented - * by that Lock implementation. + * invocation that would cause deadlock, and may throw an exception in such + * circumstances. The circumstances and the exception type must be documented by + * that Lock implementation. * + * @throws RuntimeException if an error occurs while acquiring the lock. * @throws InterruptedException * if the current thread is interrupted while acquiring the lock (and * interruption of lock acquisition is supported). */ - virtual void lockInterruptibly() throw ( decaf::lang::exceptions::InterruptedException ) = 0; + virtual void lockInterruptibly() throw ( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException ) = 0; /** * Acquires the lock only if it is free at the time of invocation. @@ -181,8 +184,10 @@ * try to unlock if the lock was not acquired. * * @returns true if the lock was acquired and false otherwise + * + * @throws RuntimeException if an error occurs while acquiring the lock. */ - virtual bool tryLock() = 0; + virtual bool tryLock() throw( decaf::lang::exceptions::RuntimeException ) = 0; /** * Acquires the lock if it is free within the given waiting time and the current @@ -234,12 +239,14 @@ * @returns true if the lock was acquired and false if the waiting time elapsed * before the lock was acquired * + * @throws RuntimeException if an error occurs while acquiring the lock. * @throws InterruptedException * if the current thread is interrupted while acquiring the lock (and * interruption of lock acquisition is supported) */ virtual bool tryLock( long long time, const TimeUnit& unit ) - throw ( decaf::lang::exceptions::InterruptedException ) = 0; + throw ( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::InterruptedException ) = 0; /** * Releases the lock. @@ -250,8 +257,10 @@ * a lock (typically only the holder of the lock can release it) and may throw an * exception if the restriction is violated. Any restrictions and the exception * type must be documented by that Lock implementation. + * + * @throws RuntimeException if an error occurs while acquiring the lock. */ - virtual void unlock() = 0; + virtual void unlock() throw( decaf::lang::exceptions::RuntimeException ) = 0; /** * Returns a new Condition instance that is bound to this Lock instance. @@ -268,11 +277,13 @@ * @returns A new Condition instance for this Lock instance the caller must * delete the returned Condition object when done with it. * + * @throws RuntimeException if an error occurs while creating the Condition. * @throws UnsupportedOperationException * if this Lock implementation does not support conditions */ virtual Condition* newCondition() - throw ( decaf::lang::exceptions::UnsupportedOperationException ) = 0; + throw ( decaf::lang::exceptions::RuntimeException, + decaf::lang::exceptions::UnsupportedOperationException ) = 0; };