Interface IgniteCondition
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidawait()Causes the current thread to wait until it is signalled or interrupted.booleanawait(long time, TimeUnit unit)Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses.longawaitNanos(long nanosTimeout)Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses.voidawaitUninterruptibly()Causes the current thread to wait until it is signalled.booleanawaitUntil(Date deadline)Causes the current thread to wait until it is signalled or interrupted, or the specified deadline elapses.Stringname()Name of ignite condition.voidsignal()Wakes up one waiting thread.voidsignalAll()Wakes up all waiting threads.
-
-
-
Method Detail
-
name
String name()
Name of ignite condition.- Returns:
- Name of ignite condition.
-
await
void await() throws IgniteInterruptedException, IgniteExceptionCauses the current thread to wait until it is signalled or interrupted.The lock associated with this
IgniteConditionis atomically released and the current thread becomes disabled for thread scheduling purposes and lies dormant until one of six things happens:- Some other thread (on any node) invokes the
signal()method for thisConditionand the current thread happens to be chosen as the thread to be awakened; or - Some other thread (on any node) invokes the
signalAll()method for thisCondition; or - Some other thread interrupts the current thread, and interruption of thread suspension is supported; or
- Some other node in grid fails, and lock is created in non-failoverSafe mode; or
- Local node is stopped; or
- A "spurious wakeup" occurs.
If lock is not broken (because of failure of lock owner node) in non-failoverSafe mode and local node is alive, before this method can return the current thread must re-acquire the lock associated with this condition. In all other cases when the thread returns it is guaranteed to hold this lock.
If the current thread:
- has its interrupted status set on entry to this method; or
- is interrupted while waiting and interruption of thread suspension is supported,
IgniteInterruptedExceptionis 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
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
awaitin interfaceCondition- Throws:
IgniteInterruptedException- if the current thread is interruptedIgniteException- if the node stopped, or node owning the lock failed in non-failoversafe mode
- Some other thread (on any node) invokes the
-
awaitUninterruptibly
void awaitUninterruptibly() throws IgniteExceptionCauses the current thread to wait until it is signalled.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 five things happens:
- Some other thread invokes the
signal()method for thisConditionand the current thread happens to be chosen as the thread to be awakened; or - Some other thread invokes the
signalAll()method for thisCondition; or - Some other node in grid fails, and lock is created in non-failoverSafe mode; or
- Local node is stopped; or
- A "spurious wakeup" occurs.
If lock is not broken (because of failure of lock owner node) in non-failoverSafe mode and local node is alive, before this method can return the current thread must re-acquire the lock associated with this condition. In all other cases, 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
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
awaitUninterruptiblyin interfaceCondition- Throws:
IgniteException- if the node stopped, or node owning the lock failed in non-failoversafe mode
- Some other thread invokes the
-
awaitNanos
long awaitNanos(long nanosTimeout) throws IgniteInterruptedException, IgniteExceptionCauses the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses.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 seven things happens:
- Some other thread invokes the
signal()method for thisConditionand the current thread happens to be chosen as the thread to be awakened; or - Some other thread invokes the
signalAll()method for thisCondition; or - Some other thread interrupts the current thread, and interruption of thread suspension is supported; or
- The specified waiting time elapses; or
- Some other node in grid fails, and lock is created in non-failoverSafe mode; or
- Local node is stopped; or
- A "spurious wakeup" occurs.
If lock is not broken (because of failure of lock owner node) in non-failoverSafe mode and local node is alive, 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:
- has its interrupted status set on entry to this method; or
- is interrupted while waiting and interruption of thread suspension is supported,
IgniteInterruptedExceptionis 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 method returns an estimate of the number of nanoseconds remaining to wait given the supplied
nanosTimeoutvalue upon return, or a value less than or equal to zero if it timed out. This value can be used to determine whether and how long to re-wait in cases where the wait returns but an awaited condition still does not hold. Typical uses of this method take the following form:boolean aMethod(long timeout, TimeUnit unit) { long nanos = unit.toNanos(timeout); lock.lock(); try { while (!conditionBeingWaitedFor()) { if (nanos <= 0L) return false; nanos = theCondition.awaitNanos(nanos); } // ... } finally { lock.unlock(); } }Design note: This method requires a nanosecond argument so as to avoid truncation errors in reporting remaining times. Such precision loss would make it difficult for programmers to ensure that total waiting times are not systematically shorter than specified when re-waits occur.
Implementation Considerations
The current thread is assumed to hold the lock associated with this
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
awaitNanosin interfaceCondition- Parameters:
nanosTimeout- the maximum time to wait, in nanoseconds- Returns:
- an estimate of the
nanosTimeoutvalue minus the time spent waiting upon return from this method. A positive value may be used as the argument to a subsequent call to this method to finish waiting out the desired time. A value less than or equal to zero indicates that no time remains. - Throws:
IgniteInterruptedException- if the current thread is interruptedIgniteException- if the node stopped, or node owning the lock failed in non-failoversafe mode
- Some other thread invokes the
-
await
boolean await(long time, TimeUnit unit) throws IgniteInterruptedException, IgniteExceptionCauses the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses. This method is behaviorally equivalent to:awaitNanos(unit.toNanos(time)) > 0- Specified by:
awaitin interfaceCondition- Parameters:
time- the maximum time to waitunit- the time unit of thetimeargument- Returns:
falseif the waiting time detectably elapsed before return from the method, elsetrue- Throws:
IgniteInterruptedException- if the current thread is interruptedIgniteException- if the node stopped, or node owning the lock failed in non-failoversafe mode
-
awaitUntil
boolean awaitUntil(Date deadline) throws IgniteInterruptedException, IgniteException
Causes the current thread to wait until it is signalled or interrupted, or the specified deadline elapses.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 seven things happens:
- Some other thread invokes the
signal()method for thisConditionand the current thread happens to be chosen as the thread to be awakened; or - Some other thread invokes the
signalAll()method for thisCondition; or - Some other thread interrupts the current thread, and interruption of thread suspension is supported; or
- Some other node in grid fails, and lock is created in non-failoverSafe mode; or
- Local node is stopped; or
- The specified deadline elapses; or
- A "spurious wakeup" occurs.
If lock is not broken (because of failure of lock owner node) in non-failoverSafe mode and local node is alive, 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:
- has its interrupted status set on entry to this method; or
- is interrupted while waiting and interruption of thread suspension is supported,
IgniteInterruptedExceptionis 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:
boolean aMethod(Date deadline) { boolean stillWaiting = true; lock.lock(); try { while (!conditionBeingWaitedFor()) { if (!stillWaiting) return false; stillWaiting = theCondition.awaitUntil(deadline); } // ... } finally { lock.unlock(); } }Implementation Considerations
The current thread is assumed to hold the lock associated with this
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
awaitUntilin interfaceCondition- Parameters:
deadline- the absolute time to wait until- Returns:
falseif the deadline has elapsed upon return, elsetrue- Throws:
IgniteInterruptedException- if the current thread is interrupted (and interruption of thread suspension is supported)IgniteException- if the node stopped, or node owning the lock failed in non-failoversafe mode
- Some other thread invokes the
-
signal
void signal() throws IgniteExceptionWakes up one waiting thread.If 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.Implementation Considerations
The current thread is assumed to hold the lock associated with this
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
signalin interfaceCondition- Throws:
IgniteException- if node is stopped or node owning the lock failed in non-failoversafe mode
-
signalAll
void signalAll() throws IgniteExceptionWakes up all waiting threads.If 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.Implementation Considerations
The current thread is assumed to hold the lock associated with this
Conditionwhen this method is called. If not, anIllegalMonitorStateExceptionwill be thrown.- Specified by:
signalAllin interfaceCondition- Throws:
IgniteException- if node is stopped or node owning the lock failed in non-failoversafe mode
-
-