activemq-cpp-3.3.0

decaf::util::concurrent::Mutex Class Reference

Mutex object that offers recursive support on all platforms as well as providing the ability to use the standard wait / notify pattern used in languages like Java. More...

#include <src/main/decaf/util/concurrent/Mutex.h>

Inheritance diagram for decaf::util::concurrent::Mutex:

Public Member Functions

 Mutex ()
 Mutex (const std::string &name)
virtual ~Mutex ()
std::string getName () const
std::string toString () const
virtual void lock ()
 Locks the object.
virtual bool tryLock ()
 Attempts to Lock the object, if the lock is already held by another thread than this method returns false.
virtual void unlock ()
 Unlocks the object.
virtual void wait ()
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs, int nanos)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void notify ()
 Signals a waiter on this object that it can now wake up and continue.
virtual void notifyAll ()
 Signals the waiters on this object that it can now wake up and continue.

Detailed Description

Mutex object that offers recursive support on all platforms as well as providing the ability to use the standard wait / notify pattern used in languages like Java.

Since:
1.0

Constructor & Destructor Documentation

decaf::util::concurrent::Mutex::Mutex ( )
decaf::util::concurrent::Mutex::Mutex ( const std::string &  name)
virtual decaf::util::concurrent::Mutex::~Mutex ( ) [virtual]

Member Function Documentation

std::string decaf::util::concurrent::Mutex::getName ( ) const
virtual void decaf::util::concurrent::Mutex::notifyAll ( ) [virtual]

Signals the waiters on this object that it can now wake up and continue.

Must have this object locked before calling.

Exceptions:
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.
RuntimeExceptionif an error occurs while notifying the waiting threads.

Implements decaf::util::concurrent::Synchronizable.

Referenced by decaf::util::StlQueue< T >::notifyAll(), decaf::util::StlMap< std::string, cms::Topic * >::notifyAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::notifyAll(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::notifyAll(), and decaf::util::AbstractCollection< cms::Connection * >::notifyAll().

std::string decaf::util::concurrent::Mutex::toString ( ) const
virtual bool decaf::util::concurrent::Mutex::tryLock ( ) [virtual]

Attempts to Lock the object, if the lock is already held by another thread than this method returns false.

Returns:
true if the lock was acquired, false if it is already held by another thread.
Exceptions:
RuntimeExceptionif an error occurs while locking the object.

Implements decaf::util::concurrent::Synchronizable.

Referenced by decaf::util::StlQueue< T >::tryLock(), decaf::util::StlMap< std::string, cms::Topic * >::tryLock(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::tryLock(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::tryLock(), and decaf::util::AbstractCollection< cms::Connection * >::tryLock().

virtual void decaf::util::concurrent::Mutex::wait ( long long  millisecs,
int  nanos 
) [virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling. This wait will timeout after the specified time interval. This method is similar to the one argument wait function except that it add a finer grained control over the amount of time that it waits by adding in the additional nanosecond argument.

NOTE: The ability to wait accurately at a nanosecond scale depends on the platform and OS that the Decaf API is running on, some systems do not provide an accurate enough clock to provide this level of granularity.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
nanosadditional time in nanoseconds with a range of 0-999999
Exceptions:
IllegalArgumentExceptionif an error occurs or the nanos argument is not in the range of [0-999999]
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif the wait is interrupted before it completes.
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.

Implements decaf::util::concurrent::Synchronizable.

virtual void decaf::util::concurrent::Mutex::wait ( long long  millisecs) [virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling. This wait will timeout after the specified time interval.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
Exceptions:
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif the wait is interrupted before it completes.
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.

Implements decaf::util::concurrent::Synchronizable.

virtual void decaf::util::concurrent::Mutex::wait ( ) [virtual]

The documentation for this class was generated from the following file: