activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
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 GMT
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 <decaf/util/Config.h>
 
+#include <decaf/util/Date.h>
 #include <decaf/lang/exceptions/InterruptedException.h>
 #include <decaf/lang/exceptions/IllegalMonitorStateException.h>
 
@@ -132,8 +133,8 @@
         virtual ~Condition() {}
 
         /**
-         * Causes the current thread to wait until it is signalled or interrupted.
-         * <p>
+         * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * 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.
-         * <p>
+         *
          * Implementation Considerations
-         * <p>
+         *
          * 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;
 
     };
 



Mime
View raw message