decaf::util::concurrent::locks::AbstractQueuedSynchronizer Class Reference

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

Inheritance diagram for decaf::util::concurrent::locks::AbstractQueuedSynchronizer:
Inheritance graph
[legend]

Data Structures

class  ConditionObject
 Condition object for this Synchronizer, which serves as the basis for other Lock objects. More...

Public Member Functions

virtual ~AbstractQueuedSynchronizer ()
void acquire (int arg)
 Acquire the lock exclusively, ignoring interrupts.
void acquireShared (int arg)
 Acquire the lock in shared mode, ignoring interrupts.
void acquireInterruptibly (int arg)
 Acquire the lock exclusively, allowing for interrupts.
void acquireSharedInterruptibly (int arg)
 Acquire the lock in shared mode, allowing interruption.
Collection
< decaf::lang::Thread * > * 
getExclusiveQueuedThreads () const
 Creates and returns a new Collection object that contains only those threads that may be waiting to acquire this Synchronization in exclusive mode.
Collection
< decaf::lang::Thread * > * 
getSharedQueuedThreads () const
 Creates and returns a new Collection object that contains only those threads that may be waiting to acquire this Synchronization in shared mode.
decaf::lang::ThreadgetFirstQueuedThread () const
 Returns the first thread queue (the thread that's been waiting the longest) if there are currently no queued threads this method returns NULL.
Collection
< decaf::lang::Thread * > * 
getQueuedThreads () const
 Creates and returns a new Collection object that contains a best effort snapshot of the threads that are currently waiting to acquire.
int getQueueLength () const
 Gets an estimated count of the number of threads that are currently waiting to acquire, this value changes dynamically so the result of this method can be invalid immediately after it is called.
Collection
< decaf::lang::Thread * > * 
getWaitingThreads (const AbstractQueuedSynchronizer::ConditionObject *condition) const
 Creates and returns a new Collection object that contains all the threads that may be waiting on the given ConditionOject instance at the time this method is called.
int getWaitQueueLength (const AbstractQueuedSynchronizer::ConditionObject *condition) const
 Gets an estimated count of the number of threads that are currently waiting on the given ConditionObject, this value changes dynamically so the result of this method can be invalid immediately after it is called.
bool hasContended () const
bool hasQueuedThreads () const
bool hasWaiters (const AbstractQueuedSynchronizer::ConditionObject *condition) const
 Returns true if there are any threads that are currently waiting on the given ConditionObject, the condition must be associated with this synchronizer instance.
bool isQueued (decaf::lang::Thread *thread) const
 Traverse the Queue if waiting threads to see if the given thread is present.
bool owns (const AbstractQueuedSynchronizer::ConditionObject *condition) const
 Checks whether the given ConditionObject uses this Synchronizer as its lock object.
bool release (int arg)
 When held in exclusive mode this method releases the Synchronizer.
bool releaseShared (int arg)
 When held in shared mode this method releases the Synchronizer.
std::string toString () const
 Gets a string that identifies this Synchronizer along with its present state.
bool tryAcquireNanos (int arg, long long nanos)
 Acquires in exclusive mode if possible, first checking if the calling thread has already been interrupted or not, then calling tryAcquire(int) at least one time and possibly more up to the given timeout, or until the calling thread is interrupted.
bool tryAcquireSharedNanos (int arg, long long nanos)
 Acquires in shared mode if possible, first checking if the calling thread has already been interrupted or not, then calling tryAcquireShared(int) at least one time and possibly more up to the given timeout, or until the calling thread is interrupted.

Protected Member Functions

 AbstractQueuedSynchronizer ()
virtual int getState () const
 Gets and returns the currently set value of this object Synchronization sate.
virtual void setState (int value)
 Sets the synchronization state to the given value.
virtual bool compareAndSetState (int expect, int update)
 Sets the synchronization state to the specified value if the current value is equal to the expected value given, otherwise no change is made.
virtual bool isHeldExclusively () const
 If the calling thread hold an exclusive lock on this synchronization then this method returns true, false otherwise.
virtual bool tryAcquire (int arg)
 Performs the actual work of attempting to acquire the lock in exclusive mode.
virtual int tryAcquireShared (int arg)
 Performs the actual work of attempting to acquire the lock in shared mode.
virtual bool tryRelease (int arg)
 Performs a release for the calling thread in exclusive mode.
virtual bool tryReleaseShared (int arg)
 Performs a release for the calling thread in shared mode.
virtual ConditionObjectcreateDefaultConditionObject ()
 Provides a means for derived classes to create a ConditionObject implemented by the basic logic implemented inside this class.

Constructor & Destructor Documentation

decaf::util::concurrent::locks::AbstractQueuedSynchronizer::AbstractQueuedSynchronizer (  )  [protected]
virtual decaf::util::concurrent::locks::AbstractQueuedSynchronizer::~AbstractQueuedSynchronizer (  )  [virtual]

Member Function Documentation

void decaf::util::concurrent::locks::AbstractQueuedSynchronizer::acquire ( int  arg  ) 

Acquire the lock exclusively, ignoring interrupts.

This method will call tryAcquire at least once and return if that succeeds, otherwise it can block and possibly spin until the lock is acquired. This method can serve as the basis for a Lock.lock() implementation.

Parameters:
arg Argument passed to tryAcquire, value is not interpreted by this class.
void decaf::util::concurrent::locks::AbstractQueuedSynchronizer::acquireInterruptibly ( int  arg  ) 

Acquire the lock exclusively, allowing for interrupts.

If the interrupt state is not already set this method will call tryAcquire at least once and return if that succeeds, otherwise it can block and possibly spin until the lock is acquired or the Thread is interrupted. This method can serve as the basis for a Lock.lockInterruptibly() implementation.

Parameters:
arg Argument passed to tryAcquire, value is not interpreted by this class.
Exceptions:
InterruptedException if the calling Thread is interrupted.
void decaf::util::concurrent::locks::AbstractQueuedSynchronizer::acquireShared ( int  arg  ) 

Acquire the lock in shared mode, ignoring interrupts.

This method will call tryAcquireShared at least once and return if that succeeds, otherwise it can block and possibly spin until the lock is acquired.

Parameters:
arg Argument passed to tryAcquireShared, value is not interpreted by this class.
void decaf::util::concurrent::locks::AbstractQueuedSynchronizer::acquireSharedInterruptibly ( int  arg  ) 

Acquire the lock in shared mode, allowing interruption.

If the interrupt state is not already set this method will call tryAcquireShared at least once and return if that succeeds, otherwise it can block and possibly spin until the lock is acquired or the Thread is interrupted.

Parameters:
arg Argument passed to tryAcquireShared, value is not interpreted by this class.
Exceptions:
InterruptedException if the calling Thread is interrupted.
virtual bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::compareAndSetState ( int  expect,
int  update 
) [protected, virtual]

Sets the synchronization state to the specified value if the current value is equal to the expected value given, otherwise no change is made.

This method is Atomic.

Parameters:
expect The value that state must have if the update is made.
update The new value to assign the state if the current value matches the expected.
Returns:
true if a change is made, false otherwise.
virtual ConditionObject* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::createDefaultConditionObject (  )  [protected, virtual]

Provides a means for derived classes to create a ConditionObject implemented by the basic logic implemented inside this class.

Can be overridden by derived classes that wish to provide their own implementation of a ConditionObject.

Returns:
a new ConditionObject that is owned by the caller.
Collection<decaf::lang::Thread*>* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getExclusiveQueuedThreads (  )  const

Creates and returns a new Collection object that contains only those threads that may be waiting to acquire this Synchronization in exclusive mode.

Returns:
a Collection pointer that contains waiting threads for exclusive acquisition. The caller owns the returned pointer.
decaf::lang::Thread* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getFirstQueuedThread (  )  const

Returns the first thread queue (the thread that's been waiting the longest) if there are currently no queued threads this method returns NULL.

Returns:
the first thread in the queue or NULL if none are currently waiting.
Collection<decaf::lang::Thread*>* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getQueuedThreads (  )  const

Creates and returns a new Collection object that contains a best effort snapshot of the threads that are currently waiting to acquire.

Returns:
a Collection pointer that contains waiting threads for lock acquisition. The caller owns the returned pointer.
int decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getQueueLength (  )  const

Gets an estimated count of the number of threads that are currently waiting to acquire, this value changes dynamically so the result of this method can be invalid immediately after it is called.

Returns:
an estimate of the number of waiting threads.
Collection<decaf::lang::Thread*>* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getSharedQueuedThreads (  )  const

Creates and returns a new Collection object that contains only those threads that may be waiting to acquire this Synchronization in shared mode.

Returns:
a Collection pointer that contains waiting threads for shared acquisition. The caller owns the returned pointer.
virtual int decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getState (  )  const [protected, virtual]

Gets and returns the currently set value of this object Synchronization sate.

Returns:
the value of the synchronization sate.
Collection<decaf::lang::Thread*>* decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getWaitingThreads ( const AbstractQueuedSynchronizer::ConditionObject condition  )  const

Creates and returns a new Collection object that contains all the threads that may be waiting on the given ConditionOject instance at the time this method is called.

Returns:
a Collection pointer that contains waiting threads on given ConditionObject. The caller owns the returned pointer.
Exceptions:
NullPointerException if the ConditionObject pointer is NULL.
IllegalArgumentException if the ConditionObject is not associated with this Synchronizer.
IllegalMonitorStateException if the caller does not hold exclusive synchronization.
int decaf::util::concurrent::locks::AbstractQueuedSynchronizer::getWaitQueueLength ( const AbstractQueuedSynchronizer::ConditionObject condition  )  const

Gets an estimated count of the number of threads that are currently waiting on the given ConditionObject, this value changes dynamically so the result of this method can be invalid immediately after it is called.

The ConditionObject must be associated with this AbstractQueuedSynchronizer or an exception will be thrown.

Returns:
an estimate of the number of waiting threads.
Exceptions:
NullPointerException if the ConditionObject pointer is NULL.
IllegalArgumentException if the ConditionObject is not associated with this Synchronizer.
IllegalMonitorStateException if the caller does not hold exclusive synchronization.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::hasContended (  )  const
Returns:
true if there has ever been the need for the acquire method to block.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::hasQueuedThreads (  )  const
Returns:
true if there are threads that are currently waiting to acquire.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::hasWaiters ( const AbstractQueuedSynchronizer::ConditionObject condition  )  const

Returns true if there are any threads that are currently waiting on the given ConditionObject, the condition must be associated with this synchronizer instance.

Returns:
true if the condition object has waiting threads.
Exceptions:
NullPointerException if the ConditionObject pointer is NULL.
IllegalArgumentException if the ConditionObject is not associated with this Synchronizer.
IllegalMonitorStateException if the caller does not hold exclusive synchronization.
virtual bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::isHeldExclusively (  )  const [protected, virtual]

If the calling thread hold an exclusive lock on this synchronization then this method returns true, false otherwise.

The default behavior is to throw an UnsupportedOperation exception as this method is only needed when ConditionObject is supported.

Returns:
true if this synchronization is held exclusively by the current thread.
Exceptions:
UnsupportedOperationException if Condition objects are not supported.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::isQueued ( decaf::lang::Thread thread  )  const

Traverse the Queue if waiting threads to see if the given thread is present.

Returns:
true if the given thread is in the wait Queue.
Exceptions:
NullPointerException if the thread pointer is NULL.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::owns ( const AbstractQueuedSynchronizer::ConditionObject condition  )  const

Checks whether the given ConditionObject uses this Synchronizer as its lock object.

Returns:
true if the ConditionObject uses this Synchronizer as its lock.
Exceptions:
NullPointerException if the condition pointer is NULL.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::release ( int  arg  ) 

When held in exclusive mode this method releases the Synchronizer.

This method calls tryRelease(int) and if one or more threads is unblocked it returns true. This method forms the basis of Lock.unlock.

Parameters:
arg A value used to release, it is passed to tryRelease and not interpreted by this class.
Returns:
the result that is returned from a call to tryRelease(int).
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::releaseShared ( int  arg  ) 

When held in shared mode this method releases the Synchronizer.

This method calls tryReleaseShared(int) and if one or more threads is unblocked it returns true.

Parameters:
arg A value used to release, it is passed to tryReleaseShared and not interpreted by this class.
Returns:
the result that is returned from a call to tryReleaseShared(int).
virtual void decaf::util::concurrent::locks::AbstractQueuedSynchronizer::setState ( int  value  )  [protected, virtual]

Sets the synchronization state to the given value.

Parameters:
value The new value to assign to the synchronization state.
std::string decaf::util::concurrent::locks::AbstractQueuedSynchronizer::toString (  )  const

Gets a string that identifies this Synchronizer along with its present state.

The string contains the state in a bracketed form that contains "State =" and the result of getState() and also contains the indicators "nonempty" or "empty" based on whether the thread queue is empty or not.

Returns:
a string value that identifies this AbstractQueuedSynchronizer.
virtual bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryAcquire ( int  arg  )  [protected, virtual]

Performs the actual work of attempting to acquire the lock in exclusive mode.

The implementation should acquire the lock in exclusive mode based on its current state or the capabilities of the lock being implemented.

Whenever a thread calls acquire this method is invoked. If the method fails then the acquire method can decide to block the calling thread until signaled that another attempt to acquire should be made.

The default implementation always throws UnsupportedOperationException.

Parameters:
arg The value passed to the acquire method.
Returns:
true if the acquire succeeded, false otherwise.
Exceptions:
IllegalMonitorStateException if the acquire places the object in an invalid state.
UnsupportedOperationException if exclusive mode is not supported.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryAcquireNanos ( int  arg,
long long  nanos 
)

Acquires in exclusive mode if possible, first checking if the calling thread has already been interrupted or not, then calling tryAcquire(int) at least one time and possibly more up to the given timeout, or until the calling thread is interrupted.

Parameters:
arg Value to be passed to tryAcquire(int) its meaning is uninterpreted here.
nanos Time in nanoseconds to wait before reporting the acquisition as failed.
Returns:
true if the acquire succeeded, false otherwise.
Exceptions:
InterruptedException if the calling thread is interrupted.
virtual int decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryAcquireShared ( int  arg  )  [protected, virtual]

Performs the actual work of attempting to acquire the lock in shared mode.

The implementation should acquire the lock in exclusive mode based on its current state or the capabilities of the lock being implemented.

Whenever a thread calls acquire this method is invoked. If the method fails then the acquire method can decide to block the calling thread until signaled that another attempt to acquire should be made.

The default implementation always throws UnsupportedOperationException.

Parameters:
arg The value passed to the acquire method.
Returns:
a negative value if the acquire failed, zero if it did succeed but no additional shared mode acquires can, or a positive number if success and future calls amy also succeed.
Exceptions:
IllegalMonitorStateException if the acquire places the object in an invalid state.
UnsupportedOperationException if shared mode is not supported.
bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryAcquireSharedNanos ( int  arg,
long long  nanos 
)

Acquires in shared mode if possible, first checking if the calling thread has already been interrupted or not, then calling tryAcquireShared(int) at least one time and possibly more up to the given timeout, or until the calling thread is interrupted.

Parameters:
arg Value to be passed to tryAcquireShared(int) its meaning is uninterpreted here.
nanos Time in nanoseconds to wait before reporting the acquisition as failed.
Returns:
true if the acquire succeeded, false otherwise.
Exceptions:
InterruptedException if the calling thread is interrupted.
virtual bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryRelease ( int  arg  )  [protected, virtual]

Performs a release for the calling thread in exclusive mode.

For any thread that performs a release this method will always be invoked.

The default implementation always throws UnsupportedOperationException.

Parameters:
arg The value that was passed to the release method.
Returns:
true if the synchronization is now fully released such that waiting threads can now attempt to acquire it, false if not fully released.
Exceptions:
IllegalMonitorStateException if the release places the object in an invalid state.
UnsupportedOperationException if exclusive mode is not supported.
virtual bool decaf::util::concurrent::locks::AbstractQueuedSynchronizer::tryReleaseShared ( int  arg  )  [protected, virtual]

Performs a release for the calling thread in shared mode.

For any thread that performs a release this method will always be invoked.

The default implementation always throws UnsupportedOperationException.

Parameters:
arg The value that was passed to the release method.
Returns:
true if the synchronization is now fully released such that waiting threads can now attempt to acquire it, false if not fully released.
Exceptions:
IllegalMonitorStateException if the release places the object in an invalid state.
UnsupportedOperationException if shared mode is not supported.

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