Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

CountDownLatch::Sync Class Reference

Inheritance diagram for CountDownLatch::Sync:

AbstractLock List of all members.

Public Member Functions

 this (int count)
int getCount ()
int tryAcquireShared (int acquires)
bool tryReleaseShared (int releases)

Private Member Functions

 this ()
Node v_head ()
void v_head (Node val)
Node v_tail ()
void v_tail (Node val)
final int state ()
final void state (int newState)
bool tryAcquire (int arg)
bool tryRelease (int arg)
bool isHeldExclusively ()
void acquire (int arg)
bool tryAcquireNanos (int arg, long nanosTimeout)
bool release (int arg)
void acquireShared (int arg)
bool tryAcquireSharedNanos (int arg, long nanosTimeout)
bool releaseShared (int arg)
bool hasQueuedThreads ()
bool hasContended ()
Thread getFirstQueuedThread ()

Private Attributes

int state_

Member Function Documentation

this int  count  )  [inline]
 

Definition at line 106 of file Countdown.d.

int getCount  )  [inline]
 

Definition at line 110 of file Countdown.d.

Referenced by CountDownLatch::count(), and CountDownLatch::toString().

int tryAcquireShared int  acquires  )  [inline]
 

Attempts to acquire in shared mode. This method should query if the state of the object permits it to be acquired in the shared mode, and if so to acquire it.

This method is always invoked by the thread performing acquire. If this method reports failure, the acquire method may queue the thread, if it is not already queued, until it is signalled by a release from some other thread.

The default implementation throws UnsupportedOperationException

Parameters:
arg the acquire argument. This value is always the one passed to an acquire method, or is the value saved on entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
a negative value on failure, zero on exclusive success, and a positive value if non-exclusively successful, in which case a subsequent waiting thread must check availability. (Support for three different return values enables this method to be used in contexts where acquires only sometimes act exclusively.) Upon success, this object has been acquired.

Reimplemented from AbstractLock.

Definition at line 114 of file Countdown.d.

bool tryReleaseShared int  releases  )  [inline]
 

Attempts to set the state to reflect a release in shared mode. This method is always invoked by the thread performing release. The default implementation throws UnsupportedOperationException.

Parameters:
arg the release argument. This value is always the one passed to a release method, or the current state value upon entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
true if this object is now in a fully released state, so that any waiting threads may attempt to acquire; and false otherwise.

Reimplemented from AbstractLock.

Definition at line 118 of file Countdown.d.

this  )  [inline, protected, inherited]
 

Creates a new AbstractLock instance with initial synchronization state of zero.

Definition at line 238 of file LockImpl.d.

Node v_head  )  [inline, inherited]
 

Definition at line 448 of file LockImpl.d.

References AbstractLock::head.

Referenced by AbstractLock::acquireQueued(), AbstractLock::doAcquireNanos(), AbstractLock::doAcquireShared(), AbstractLock::doAcquireSharedNanos(), and AbstractLock::hasContended().

void v_head Node  val  )  [inline, inherited]
 

Definition at line 449 of file LockImpl.d.

References AbstractLock::head.

Node v_tail  )  [inline, inherited]
 

Definition at line 456 of file LockImpl.d.

References AbstractLock::tail.

Referenced by AbstractLock::addWaiter(), AbstractLock::enq(), AbstractLock::findNodeFromTail(), AbstractLock::getExclusiveQueuedThreads(), AbstractLock::getQueuedThreads(), AbstractLock::getQueueLength(), AbstractLock::getSharedQueuedThreads(), and AbstractLock::isQueued().

void v_tail Node  val  )  [inline, inherited]
 

Definition at line 457 of file LockImpl.d.

References AbstractLock::tail.

final int state  )  [inline, protected, inherited]
 

Returns the current value of synchronization state. This operation has memory semantics of a volatile read.

Returns:
current state value

Definition at line 469 of file LockImpl.d.

References AbstractLock::state_.

Referenced by AbstractLock::fullyRelease(), and AbstractLock::toString().

final void state int  newState  )  [inline, protected, inherited]
 

Sets the value of synchronization state. This operation has memory semantics of a volatile write.

Parameters:
newState the new state value

Definition at line 478 of file LockImpl.d.

References AbstractLock::state_.

bool tryAcquire int  arg  )  [inline, protected, inherited]
 

Attempts to acquire in exclusive mode. This method should query if the state of the object permits it to be acquired in the exclusive mode, and if so to acquire it.

This method is always invoked by the thread performing acquire. If this method reports failure, the acquire method may queue the thread, if it is not already queued, until it is signalled by a release from some other thread. This can be used to implement method tryLock().

The default implementation throws UnsupportedOperationException

Parameters:
arg the acquire argument. This value is always the one passed to an acquire method, or is the value saved on entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
true if successful. Upon success, this object has been acquired.

Reimplemented in ReentrantReadWriteLock::NonfairSync, ReentrantReadWriteLock::FairSync, ReentrantLock::NonfairSync, and ReentrantLock::FairSync.

Definition at line 819 of file LockImpl.d.

Referenced by AbstractLock::acquire(), AbstractLock::acquireQueued(), AbstractLock::doAcquireNanos(), and AbstractLock::tryAcquireNanos().

bool tryRelease int  arg  )  [inline, protected, inherited]
 

Attempts to set the state to reflect a release in exclusive mode. This method is always invoked by the thread performing release.

The default implementation throws UnsupportedOperationException

Parameters:
arg the release argument. This value is always the one passed to a release method, or the current state value upon entry to a condition wait. The value is otherwise uninterpreted and can represent anything you like.
Returns:
true if this object is now in a fully released state, so that any waiting threads may attempt to acquire; and false otherwise.

Reimplemented in ReentrantReadWriteLock::Sync, and ReentrantLock::Sync.

Definition at line 840 of file LockImpl.d.

Referenced by AbstractLock::release().

bool isHeldExclusively  )  [inline, inherited]
 

Returns true if synchronization is held exclusively with respect to the current (calling) thread. This method is invoked upon each call to a non-waiting ConditionObject method. (Waiting methods instead invoke release.)

The default implementation throws UnsupportedOperationException. This method is invoked internally only within ConditionObject methods, so need not be defined if conditions are not used.

Returns:
true if synchronization is held exclusively; else false

Reimplemented in ReentrantReadWriteLock::Sync, and ReentrantLock::Sync.

Definition at line 908 of file LockImpl.d.

Referenced by AbstractLock::ConditionObject::getWaitingThreads(), AbstractLock::ConditionObject::getWaitQueueLength(), AbstractLock::ConditionObject::hasWaiters(), AbstractLock::ConditionObject::notify(), and AbstractLock::ConditionObject::notifyAll().

void acquire int  arg  )  [inline, inherited]
 

Acquires in exclusive mode. Implemented by invoking at least once tryAcquire, returning on success. Otherwise the thread is queued, possibly repeatedly blocking and unblocking, invoking tryAcquire until success. This method can be used to implement method Lock.lock

Parameters:
arg the acquire argument. This value is conveyed to tryAcquire but is otherwise uninterpreted and can represent anything you like.

Definition at line 924 of file LockImpl.d.

References AbstractLock::acquireQueued(), AbstractLock::addWaiter(), and AbstractLock::tryAcquire().

Referenced by ReentrantLock::FairSync::lock(), ReentrantLock::NonfairSync::lock(), ReentrantReadWriteLock::FairSync::wlock(), and ReentrantReadWriteLock::NonfairSync::wlock().

bool tryAcquireNanos int  arg,
long  nanosTimeout
[inline, inherited]
 

Attempts to acquire in exclusive mode and failing if the given timeout elapses. Implemented by first checking interrupt status, then invoking at least once tryAcquire, returning on success. Otherwise, the thread is queued, possibly repeatedly blocking and unblocking, invoking tryAcquire until success or the timeout elapses. This method can be used to implement method Lock.tryLock(long, TimeUnit).

Parameters:
arg the acquire argument. This value is conveyed to tryAcquire but is otherwise uninterpreted and can represent anything you like.
nanosTimeout the maximum number of nanoseconds to wait
Returns:
true if acquired; false if timed out

Definition at line 944 of file LockImpl.d.

References AbstractLock::doAcquireNanos(), and AbstractLock::tryAcquire().

Referenced by ReentrantLock::tryLock(), and ReentrantReadWriteLock::WriteLock::tryLock().

bool release int  arg  )  [inline, inherited]
 

Releases in exclusive mode. Implemented by unblocking one or more threads if tryRelease returns true. This method can be used to implement method Lock.unlock

Parameters:
arg the release argument. This value is conveyed to tryRelease but is otherwise uninterpreted and can represent anything you like.
Returns:
the value returned from tryRelease

Definition at line 959 of file LockImpl.d.

References AbstractLock::head, AbstractLock::tryRelease(), AbstractLock::unparkSuccessor(), and AbstractLock::Node::waitStatus.

Referenced by AbstractLock::fullyRelease(), ReentrantLock::unlock(), and ReentrantReadWriteLock::WriteLock::unlock().

void acquireShared int  arg  )  [inline, inherited]
 

Acquires in shared mode. Implemented by first invoking at least once tryAcquireShared, returning on success. Otherwise the thread is queued, possibly repeatedly blocking and unblocking, invoking tryAcquireShared until success.

Parameters:
arg the acquire argument. This value is conveyed to tryAcquireShared but is otherwise uninterpreted and can represent anything you like.

Definition at line 981 of file LockImpl.d.

References AbstractLock::doAcquireShared(), and AbstractLock::tryAcquireShared().

Referenced by Semaphore::acquire(), ReentrantReadWriteLock::ReadLock::lock(), and CountDownLatch::wait().

bool tryAcquireSharedNanos int  arg,
long  nanosTimeout
[inline, inherited]
 

Attempts to acquire in shared mode and failing if the given timeout elapses. Implemented by invoking at least once tryAcquireShared, returning on success. Otherwise, the thread is queued, possibly repeatedly blocking and unblocking, invoking tryAcquireShared until success or the timeout elapses.

Parameters:
arg the acquire argument. This value is conveyed to tryAcquireShared but is otherwise uninterpreted and can represent anything you like.
nanosTimeout the maximum number of nanoseconds to wait
Returns:
true if acquired; false if timed out

Definition at line 999 of file LockImpl.d.

References AbstractLock::doAcquireSharedNanos(), and AbstractLock::tryAcquireShared().

Referenced by Semaphore::tryAcquire(), ReentrantReadWriteLock::ReadLock::tryLock(), and CountDownLatch::wait().

bool releaseShared int  arg  )  [inline, inherited]
 

Releases in shared mode. Implemented by unblocking one or more threads if tryReleaseShared returns true.

Parameters:
arg the release argument. This value is conveyed to tryReleaseShared but is otherwise uninterpreted and can represent anything you like.
Returns:
the value returned from tryReleaseShared

Definition at line 1012 of file LockImpl.d.

References AbstractLock::head, AbstractLock::tryReleaseShared(), AbstractLock::unparkSuccessor(), and AbstractLock::Node::waitStatus.

Referenced by CountDownLatch::countDown(), Semaphore::release(), and ReentrantReadWriteLock::ReadLock::unlock().

bool hasQueuedThreads  )  [inline, inherited]
 

Queries whether any threads are waiting to acquire. Note that because cancellations due to interrupts and timeouts may occur at any time, a true return does not guarantee that any other thread will ever acquire.

In this implementation, this operation returns in constant time.

Returns:
true if there may be other threads waiting to acquire the lock.

Definition at line 1038 of file LockImpl.d.

References AbstractLock::head, and AbstractLock::tail.

Referenced by Semaphore::hasQueuedThreads(), ReentrantLock::hasQueuedThreads(), ReentrantReadWriteLock::hasQueuedThreads(), and AbstractLock::toString().

bool hasContended  )  [inline, inherited]
 

Queries whether any threads have ever contended to acquire this synchronizer; that is if an acquire method has ever blocked.

In this implementation, this operation returns in constant time.

Returns:
true if there has ever been contention

Definition at line 1051 of file LockImpl.d.

References AbstractLock::v_head().

Thread getFirstQueuedThread  )  [inline, inherited]
 

Returns the first (longest-waiting) thread in the queue, or null if no threads are currently queued.

In this implementation, this operation normally returns in constant time, but may iterate upon contention if other threads are concurrently modifying the queue.

Returns:
the first (longest-waiting) thread in the queue, or null if no threads are currently queued.

Definition at line 1066 of file LockImpl.d.

References AbstractLock::fullGetFirstQueuedThread(), AbstractLock::head, and AbstractLock::tail.

Referenced by ReentrantLock::FairSync::tryAcquire(), ReentrantReadWriteLock::FairSync::tryAcquire(), Semaphore::FairSync::tryAcquireShared(), and ReentrantReadWriteLock::FairSync::tryAcquireShared().


Member Data Documentation

int state_ [protected, inherited]
 

The synchronization state.

Definition at line 462 of file LockImpl.d.

Referenced by AbstractLock::state().


The documentation for this class was generated from the following file:
Generated on Mon Nov 14 10:59:51 2005 for Mango by  doxygen 1.4.0