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:
Inheritance graph
[legend]

Public Member Functions

 Mutex ()
 Mutex (const std::string &name)
virtual ~Mutex ()
std::string getName () const
std::string toString () const
bool isLocked () 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
bool decaf::util::concurrent::Mutex::isLocked (  )  const
virtual void decaf::util::concurrent::Mutex::lock (  )  [virtual]
virtual void decaf::util::concurrent::Mutex::notify (  )  [virtual]

Signals a waiter 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.
RuntimeException if an error occurs while notifying one of the waiting threads.

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

Referenced by decaf::util::StlQueue< T >::notify(), decaf::util::StlMap< std::string, cms::Topic * >::notify(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::notify(), decaf::util::AbstractMap< E, Set< E > * >::notify(), and decaf::util::AbstractCollection< K >::notify().

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.
RuntimeException if 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::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::notifyAll(), decaf::util::AbstractMap< E, Set< E > * >::notifyAll(), and decaf::util::AbstractCollection< K >::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:
RuntimeException if 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::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::tryLock(), decaf::util::AbstractMap< E, Set< E > * >::tryLock(), and decaf::util::AbstractCollection< K >::tryLock().

virtual void decaf::util::concurrent::Mutex::unlock (  )  [virtual]
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:
millisecs the time in milliseconds to wait, or WAIT_INIFINITE
nanos additional time in nanoseconds with a range of 0-999999
Exceptions:
IllegalArgumentException if an error occurs or the nanos argument is not in the range of [0-999999]
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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:
millisecs the time in milliseconds to wait, or WAIT_INIFINITE
Exceptions:
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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]

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

Must have this object locked before calling.

Exceptions:
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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.

Referenced by decaf::util::StlQueue< T >::wait(), decaf::util::StlMap< std::string, cms::Topic * >::wait(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::wait(), decaf::util::AbstractMap< E, Set< E > * >::wait(), and decaf::util::AbstractCollection< K >::wait().


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

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1