activemq-cpp-3.6.0
|
#include <src/main/decaf/util/concurrent/locks/ReentrantReadWriteLock.h>
Public Member Functions | |
ReentrantReadWriteLock () | |
Creates a new ReentrantReadWriteLock with the default ordering property of Not-Fair. | |
ReentrantReadWriteLock (bool fair) | |
Creates a new ReentrantReadWriteLock with the given fairness policy. | |
virtual | ~ReentrantReadWriteLock () |
virtual decaf::util::concurrent::locks::Lock & | readLock () |
Returns the lock used for reading.
| |
virtual decaf::util::concurrent::locks::Lock & | writeLock () |
Returns the lock used for writing.
| |
bool | isFair () const |
Returns true if this lock has fairness set true. | |
int | getReadLockCount () const |
Queries the number of read locks held for this lock. | |
bool | isWriteLocked () const |
Queries if the write lock is held by any thread. | |
bool | isWriteLockedByCurrentThread () const |
Queries if the write lock is held by the current thread. | |
int | getWriteHoldCount () const |
Queries the number of reentrant write holds on this lock by the current thread. | |
int | getReadHoldCount () const |
Queries the number of reentrant read holds on this lock by the current thread. | |
bool | hasWaiters (Condition *condition) const |
Queries whether any threads are waiting on the given condition associated with the write lock. | |
int | getWaitQueueLength (Condition *condition) const |
Gets an estimated count of the number of threads that are currently waiting on the given Condition object, this value changes dynamically so the result of this method can be invalid immediately after it is called. | |
std::string | toString () const |
Returns a string identifying this lock, as well as its lock state. | |
bool | hasQueuedThreads () const |
Queries whether any threads are waiting to acquire the read or write lock. | |
bool | hasQueuedThread (decaf::lang::Thread *thread) const |
Queries whether the given thread is waiting to acquire either the read or write lock. | |
int | getQueueLength () const |
Returns an estimate of the number of threads waiting to acquire either the read or write lock. | |
Public Member Functions inherited from decaf::util::concurrent::locks::ReadWriteLock | |
virtual | ~ReadWriteLock () |
Protected Member Functions | |
decaf::util::Collection < decaf::lang::Thread * > * | getWaitingThreads (Condition *condition) const |
Creates and returns a new Collection object that contains all the threads that may be waiting on the given Condition object instance at the time this method is called. | |
decaf::util::Collection < decaf::lang::Thread * > * | getQueuedThreads () const |
Returns a collection containing threads that may be waiting to acquire either the read or write lock. | |
decaf::util::Collection < decaf::lang::Thread * > * | getQueuedWriterThreads () const |
Returns a collection containing threads that may be waiting to acquire the write lock. | |
decaf::util::Collection < decaf::lang::Thread * > * | getQueuedReaderThreads () const |
Returns a collection containing threads that may be waiting to acquire the read lock. | |
decaf::lang::Thread * | getOwner () const |
Returns the thread that currently owns the write lock, or NULL if not owned. |
decaf::util::concurrent::locks::ReentrantReadWriteLock::ReentrantReadWriteLock | ( | ) |
Creates a new ReentrantReadWriteLock with the default ordering property of Not-Fair.
decaf::util::concurrent::locks::ReentrantReadWriteLock::ReentrantReadWriteLock | ( | bool | fair | ) |
Creates a new ReentrantReadWriteLock with the given fairness policy.
fair | Boolean value indicating whether this lock uses a fair or non-fair policy. |
|
virtual |
|
protected |
Returns the thread that currently owns the write lock, or NULL if not owned.
When this method is called by a thread that is not the owner, the return value reflects a best-effort approximation of current lock status. For example, the owner may be momentarily NULL even if there are threads trying to acquire the lock but have not yet done so. This method is designed to facilitate construction of subclasses that provide more extensive lock monitoring facilities.
|
protected |
Returns a collection containing threads that may be waiting to acquire the read lock.
Because the actual set of threads may change dynamically while constructing this result, the returned collection is only a best-effort estimate. The elements of the returned collection are in no particular order. This method is designed to facilitate construction of subclasses that provide more extensive lock monitoring facilities.
|
protected |
Returns a collection containing threads that may be waiting to acquire either the read or write lock.
Because the actual set of threads may change dynamically while constructing this result, the returned collection is only a best-effort estimate. The elements of the returned collection are in no particular order. This method is designed to facilitate construction of subclasses that provide more extensive monitoring facilities.
|
protected |
Returns a collection containing threads that may be waiting to acquire the write lock.
Because the actual set of threads may change dynamically while constructing this result, the returned collection is only a best-effort estimate. The elements of the returned collection are in no particular order. This method is designed to facilitate construction of subclasses that provide more extensive lock monitoring facilities.
int decaf::util::concurrent::locks::ReentrantReadWriteLock::getQueueLength | ( | ) | const |
Returns an estimate of the number of threads waiting to acquire either the read or write lock.
The value is only an estimate because the number of threads may change dynamically while this method traverses internal data structures. This method is designed for use in monitoring of the system state, not for synchronization control.
int decaf::util::concurrent::locks::ReentrantReadWriteLock::getReadHoldCount | ( | ) | const |
Queries the number of reentrant read holds on this lock by the current thread.
A reader thread has a hold on a lock for each lock action that is not matched by an unlock action.
int decaf::util::concurrent::locks::ReentrantReadWriteLock::getReadLockCount | ( | ) | const |
Queries the number of read locks held for this lock.
This method is designed for use in monitoring system state, not for synchronization control.
|
protected |
Creates and returns a new Collection object that contains all the threads that may be waiting on the given Condition object instance at the time this method is called.
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::ReentrantReadWriteLock::getWaitQueueLength | ( | Condition * | condition | ) | const |
Gets an estimated count of the number of threads that are currently waiting on the given Condition object, this value changes dynamically so the result of this method can be invalid immediately after it is called.
The Condition object must be associated with this Lock or an exception will be thrown.
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::ReentrantReadWriteLock::getWriteHoldCount | ( | ) | const |
Queries the number of reentrant write holds on this lock by the current thread.
A writer thread has a hold on a lock for each lock action that is not matched by an unlock action.
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::hasQueuedThread | ( | decaf::lang::Thread * | thread | ) | const |
Queries whether the given thread is waiting to acquire either the read or write lock.
Note that because cancellations may occur at any time, a true return does not guarantee that this thread will ever acquire a lock. This method is designed primarily for use in monitoring of the system state.
thread | The thread that will be queried for. |
NullPointerException | if the thread is NULL. |
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::hasQueuedThreads | ( | ) | const |
Queries whether any threads are waiting to acquire the read or write lock.
Note that because cancellations may occur at any time, a true return does not guarantee that any other thread will ever acquire a lock. This method is designed primarily for use in monitoring of the system state.
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::hasWaiters | ( | Condition * | condition | ) | const |
Queries whether any threads are waiting on the given condition associated with the write lock.
Note that because timeouts and interrupts may occur at any time, a true return does not guarantee that a future signal will awaken any threads. This method is designed primarily for use in monitoring of the system state.
condition | The condition to be queried for waiters. |
NullPointerException | if the ConditionObject pointer is NULL. |
IllegalArgumentException | if the ConditionObject is not associated with this Lock. |
IllegalMonitorStateException | if the caller does not hold exclusive synchronization. |
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::isFair | ( | ) | const |
Returns true if this lock has fairness set true.
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::isWriteLocked | ( | ) | const |
Queries if the write lock is held by any thread.
This method is designed for use in monitoring system state, not for synchronization control.
bool decaf::util::concurrent::locks::ReentrantReadWriteLock::isWriteLockedByCurrentThread | ( | ) | const |
Queries if the write lock is held by the current thread.
|
virtual |
Returns the lock used for reading.
Implements decaf::util::concurrent::locks::ReadWriteLock.
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< E >::contains(), decaf::util::concurrent::CopyOnWriteArrayList< E >::get(), decaf::util::concurrent::CopyOnWriteArrayList< E >::indexOf(), decaf::util::concurrent::CopyOnWriteArrayList< E >::isEmpty(), decaf::util::concurrent::CopyOnWriteArrayList< E >::iterator(), decaf::util::concurrent::CopyOnWriteArrayList< E >::lastIndexOf(), decaf::util::concurrent::CopyOnWriteArrayList< E >::listIterator(), decaf::util::concurrent::CopyOnWriteArrayList< E >::size(), decaf::util::concurrent::CopyOnWriteArrayList< E >::toArray(), and decaf::util::concurrent::CopyOnWriteArrayList< E >::toString().
std::string decaf::util::concurrent::locks::ReentrantReadWriteLock::toString | ( | ) | const |
Returns a string identifying this lock, as well as its lock state.
The state, in brackets, includes the String "Write locks =" followed by the number of reentrantly held write locks, and the String "Read locks =" followed by the number of held read locks.
|
virtual |
Returns the lock used for writing.
Implements decaf::util::concurrent::locks::ReadWriteLock.
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< E >::add(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addAllAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addIfAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< E >::clear(), decaf::util::concurrent::CopyOnWriteArrayList< E >::copy(), decaf::util::concurrent::CopyOnWriteArrayList< E >::CopyOnWriteArrayList(), decaf::util::concurrent::CopyOnWriteArrayList< E >::lock(), decaf::util::concurrent::CopyOnWriteArrayList< E >::operator=(), decaf::util::concurrent::CopyOnWriteArrayList< E >::remove(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAt(), decaf::util::concurrent::CopyOnWriteArrayList< E >::retainAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::set(), decaf::util::concurrent::CopyOnWriteArrayList< E >::tryLock(), and decaf::util::concurrent::CopyOnWriteArrayList< E >::unlock().