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

AbstractLock::ConditionObject Class Reference

Inheritance diagram for AbstractLock::ConditionObject:

Condition List of all members.

Public Member Functions

 this (AbstractLock parent)

Private Member Functions

Node addConditionWaiter ()
void doNotify (Node first)
void doNotifyAll (Node first)
void notify ()
void notifyAll ()
void wait ()
long waitNanos (long nanosTimeout)
bool wait (long time, TimeUnit unit)
bool isOwnedBy (AbstractLock sync)
bool hasWaiters ()
int getWaitQueueLength ()
Thread[] getWaitingThreads ()

Private Attributes

Node firstWaiter
Node lastWaiter
AbstractLock parent

Detailed Description

Condition implementation for a AbstractLock serving as the basis of a Lock implementation.

Method documentation for this class describes mechanics, not behavioral specifications from the point of view of Lock and Condition users. Exported versions of this class will in general need to be accompanied by documentation describing condition semantics that rely on those of the associated AbstractLock.

This class is Serializable, but all fields are transient, so deserialized conditions have no waiters.

Definition at line 1448 of file LockImpl.d.


Member Function Documentation

this AbstractLock  parent  )  [inline]
 

Creates a new ConditionObject instance.

Definition at line 1457 of file LockImpl.d.

References parent.

Node addConditionWaiter  )  [inline, private]
 

Add a new waiter to wait queue

Returns:
its new wait node

Definition at line 1467 of file LockImpl.d.

References firstWaiter, lastWaiter, AbstractLock::Node::nextWaiter, and Node.

Referenced by wait(), and waitNanos().

void doNotify Node  first  )  [inline, private]
 

Remove and transfer nodes until hit non-cancelled one or null. Split out from signal in part to encourage compilers to inline the case of no waiters.

Parameters:
first (non-null) the first node on condition queue

Definition at line 1484 of file LockImpl.d.

References firstWaiter, lastWaiter, AbstractLock::Node::nextWaiter, parent, and AbstractLock::transferForNotify().

Referenced by notify().

void doNotifyAll Node  first  )  [inline, private]
 

Remove and transfer all nodes.

Parameters:
first (non-null) the first node on condition queue

Definition at line 1497 of file LockImpl.d.

References firstWaiter, lastWaiter, AbstractLock::Node::nextWaiter, parent, and AbstractLock::transferForNotify().

Referenced by notifyAll().

void notify  )  [inline, private]
 

Moves the longest-waiting thread, if one exists, from the wait queue for this condition to the wait queue for the owning lock.

Reimplemented from Condition.

Definition at line 1514 of file LockImpl.d.

References doNotify(), firstWaiter, AbstractLock::isHeldExclusively(), and parent.

void notifyAll  )  [inline, private]
 

Moves all threads from the wait queue for this condition to the wait queue for the owning lock.

Reimplemented from Condition.

Definition at line 1526 of file LockImpl.d.

References doNotifyAll(), firstWaiter, AbstractLock::isHeldExclusively(), and parent.

void wait  )  [inline, private]
 

Causes the current thread to wait until it is notified.

The lock associated with this Condition is atomically released and the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:

  • Some other thread invokes the notify method for this Condition and the current thread happens to be chosen as the thread to be awakened; or
  • Some other thread invokes the notifyAll method for this Condition; or
  • A "spurious wakeup" occurs

In all cases, before this method can return the current thread must re-acquire the lock associated with this condition. When the thread returns it is guaranteed to hold this lock.

Implementation Considerations

The current thread is assumed to hold the lock associated with this Condition when this method is called. It is up to the implementation to determine if this is the case and if not, how to respond.

Reimplemented from Condition.

Definition at line 1544 of file LockImpl.d.

References AbstractLock::acquireQueued(), addConditionWaiter(), AbstractLock::fullyRelease(), AbstractLock::isOnSyncQueue(), parent, and version.

long waitNanos long  nanosTimeout  )  [inline, private]
 

Implements timed condition wait.

  1. Save lock state returned by state()
  2. Invoke release with saved state as argument
  3. Block until signalled or timed out
  4. Reacquire by invoking specialized version of acquire with saved state as argument.

Reimplemented from Condition.

Definition at line 1566 of file LockImpl.d.

References AbstractLock::acquireQueued(), addConditionWaiter(), AbstractLock::fullyRelease(), AbstractLock::isOnSyncQueue(), parent, sleepNanos(), and AbstractLock::transferAfterCancelledWait().

bool wait long  time,
TimeUnit  unit
[inline, private]
 

Implements timed condition wait.

  1. Save lock state returned by state()
  2. Invoke release with saved state as argument
  3. Block until signalled, interrupted, or timed out
  4. Reacquire by invoking specialized version of acquire with saved state as argument.
  5. If interrupted while blocked in step 4, throw InterruptedException
  6. If timed out while blocked in step 4, return false, else true

Reimplemented from Condition.

Definition at line 1596 of file LockImpl.d.

References AbstractLock::acquireQueued(), addConditionWaiter(), AbstractLock::fullyRelease(), AbstractLock::isOnSyncQueue(), parent, sleepNanos(), toNanos(), and AbstractLock::transferAfterCancelledWait().

bool isOwnedBy AbstractLock  sync  )  [inline, private]
 

Returns true if this condition was created by the given synchronization object

Returns:
true if owned

Definition at line 1623 of file LockImpl.d.

References parent.

Referenced by AbstractLock::owns().

bool hasWaiters  )  [inline, private]
 

Queries whether any threads are waiting on this condition. Implements AbstractLock.hasWaiters

Returns:
true if there are any waiting threads.

Definition at line 1633 of file LockImpl.d.

References firstWaiter, AbstractLock::isHeldExclusively(), AbstractLock::Node::nextWaiter, and parent.

Referenced by AbstractLock::hasWaiters().

int getWaitQueueLength  )  [inline, private]
 

Returns an estimate of the number of threads waiting on this condition. Implements AbstractLock.getWaitQueueLength

Returns:
the estimated number of waiting threads.

Definition at line 1649 of file LockImpl.d.

References firstWaiter, AbstractLock::isHeldExclusively(), AbstractLock::Node::nextWaiter, and parent.

Referenced by AbstractLock::getWaitQueueLength().

Thread [] getWaitingThreads  )  [inline, private]
 

Returns a collection containing those threads that may be waiting on this Condition. Implements AbstractLock.getWaitingThreads

Returns:
the collection of threads

Definition at line 1666 of file LockImpl.d.

References firstWaiter, AbstractLock::isHeldExclusively(), AbstractLock::Node::nextWaiter, and parent.

Referenced by AbstractLock::getWaitingThreads().


Member Data Documentation

Node firstWaiter [private]
 

First node of condition queue.

Definition at line 1450 of file LockImpl.d.

Referenced by addConditionWaiter(), doNotify(), doNotifyAll(), getWaitingThreads(), getWaitQueueLength(), hasWaiters(), notify(), and notifyAll().

Node lastWaiter [private]
 

Last node of condition queue.

Definition at line 1452 of file LockImpl.d.

Referenced by addConditionWaiter(), doNotify(), and doNotifyAll().

AbstractLock parent [private]
 

Definition at line 1453 of file LockImpl.d.

Referenced by doNotify(), doNotifyAll(), getWaitingThreads(), getWaitQueueLength(), hasWaiters(), isOwnedBy(), notify(), notifyAll(), this(), wait(), and waitNanos().


The documentation for this class was generated from the following file:
Generated on Fri Nov 11 18:44:30 2005 for Mango by  doxygen 1.4.0