|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.compass.core.util.backport.java.util.concurrent.locks.CondVar
org.compass.core.util.backport.java.util.concurrent.locks.FIFOCondVar
class FIFOCondVar
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.compass.core.util.backport.java.util.concurrent.locks.CondVar |
|---|
CondVar.ExclusiveLock |
| Field Summary |
|---|
| Fields inherited from class org.compass.core.util.backport.java.util.concurrent.locks.CondVar |
|---|
lock |
| Constructor Summary | |
|---|---|
FIFOCondVar(CondVar.ExclusiveLock lock)
Create a new CondVar that relies on the given mutual exclusion lock. |
|
| Method Summary | |
|---|---|
void |
await()
Causes the current thread to wait until it is signalled or interrupted. |
boolean |
await(long timeout,
TimeUnit unit)
Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses. |
void |
awaitUninterruptibly()
Causes the current thread to wait until it is signalled. |
boolean |
awaitUntil(Date deadline)
Causes the current thread to wait until it is signalled or interrupted, or the specified deadline elapses. |
protected Collection |
getWaitingThreads()
|
protected int |
getWaitQueueLength()
|
protected boolean |
hasWaiters()
|
void |
signal()
Wakes up one waiting thread. |
void |
signalAll()
Wakes up all waiting threads. |
| Methods inherited from class org.compass.core.util.backport.java.util.concurrent.locks.CondVar |
|---|
getLock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
FIFOCondVar(CondVar.ExclusiveLock lock)
lock - A non-reentrant mutual exclusion lock.| Method Detail |
|---|
public void awaitUninterruptibly()
ConditionThe 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:
Condition.signal() method for this
Condition and the current thread happens to be chosen as the
thread to be awakened; or
Condition.signalAll() method for this
Condition; or
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.
If the current thread's interrupted status is set when it enters this method, or it is interrupted while waiting, it will continue to wait until signalled. When it finally returns from this method its interrupted status will still be set.
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. Typically, an exception will be
thrown (such as IllegalMonitorStateException) and the
implementation must document that fact.
awaitUninterruptibly in interface ConditionawaitUninterruptibly in class CondVar
public void await()
throws InterruptedException
ConditionThe lock associated with this Condition is atomically
released and the current thread becomes disabled for thread scheduling
purposes and lies dormant until one of four things happens:
Condition.signal() method for this
Condition and the current thread happens to be chosen as the
thread to be awakened; or
Condition.signalAll() method for this
Condition; or
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.
If the current thread:
InterruptedException is thrown and the current thread's
interrupted status is cleared. It is not specified, in the first
case, whether or not the test for interruption occurs before the lock
is released.
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. Typically, an exception will be
thrown (such as IllegalMonitorStateException) and the
implementation must document that fact.
An implementation can favor responding to an interrupt over normal method return in response to a signal. In that case the implementation must ensure that the signal is redirected to another waiting thread, if there is one.
await in interface Conditionawait in class CondVarInterruptedException - if the current thread is interrupted
(and interruption of thread suspension is supported)
public boolean await(long timeout,
TimeUnit unit)
throws InterruptedException
ConditionawaitNanos(unit.toNanos(time)) > 0
await in interface Conditionawait in class CondVartimeout - the maximum time to waitunit - the time unit of the time argument
false if the waiting time detectably elapsed
before return from the method, else true
InterruptedException - if the current thread is interrupted
(and interruption of thread suspension is supported)
public boolean awaitUntil(Date deadline)
throws InterruptedException
ConditionThe lock associated with this condition is atomically released and the current thread becomes disabled for thread scheduling purposes and lies dormant until one of five things happens:
Condition.signal() method for this
Condition and the current thread happens to be chosen as the
thread to be awakened; or
Condition.signalAll() method for this
Condition; or
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.
If the current thread:
InterruptedException is thrown and the current thread's
interrupted status is cleared. It is not specified, in the first
case, whether or not the test for interruption occurs before the lock
is released.
The return value indicates whether the deadline has elapsed, which can be used as follows:
synchronized boolean aMethod(Date deadline) {
boolean stillWaiting = true;
while (!conditionBeingWaitedFor) {
if (stillWaiting)
stillWaiting = theCondition.awaitUntil(deadline);
else
return false;
}
// ...
}
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. Typically, an exception will be
thrown (such as IllegalMonitorStateException) and the
implementation must document that fact.
An implementation can favor responding to an interrupt over normal method return in response to a signal, or over indicating the passing of the specified deadline. In either case the implementation must ensure that the signal is redirected to another waiting thread, if there is one.
awaitUntil in interface ConditionawaitUntil in class CondVardeadline - the absolute time to wait until
false if the deadline has elapsed upon return, else
true
InterruptedException - if the current thread is interrupted
(and interruption of thread suspension is supported)public void signal()
ConditionIf any threads are waiting on this condition then one
is selected for waking up. That thread must then re-acquire the
lock before returning from await.
signal in interface Conditionsignal in class CondVarpublic void signalAll()
ConditionIf any threads are waiting on this condition then they are
all woken up. Each thread must re-acquire the lock before it can
return from await.
signalAll in interface ConditionsignalAll in class CondVarprotected boolean hasWaiters()
hasWaiters in class CondVarprotected int getWaitQueueLength()
getWaitQueueLength in class CondVarprotected Collection getWaitingThreads()
getWaitingThreads in class CondVar
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||