Modifier and Type | Method and Description |
---|---|
void |
await()
Causes the current thread to wait until it is signalled or
interrupted.
|
boolean |
await(long time,
TimeUnit unit)
Causes the current thread to wait until it is signalled or interrupted,
or the specified waiting time elapses.
|
long |
awaitNanos(long nanosTimeout)
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.
|
String |
name()
Name of ignite condition.
|
void |
signal()
Wakes up one waiting thread.
|
void |
signalAll()
Wakes up all waiting threads.
|
String name()
void await() throws IgniteInterruptedException, IgniteException
The lock associated with this IgniteCondition
is atomically
released and the current thread becomes disabled for thread scheduling
purposes and lies dormant until one of six things happens:
signal()
method for this
Condition
and the current thread happens to be chosen as the
thread to be awakened; or
signalAll()
method for this
Condition
; or
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:
IgniteInterruptedException
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. If not, an IllegalMonitorStateException
will be thrown.
await
in interface Condition
IgniteInterruptedException
- if the current thread is interruptedIgniteException
- if the node stopped, or
node owning the lock failed in non-failoversafe modevoid awaitUninterruptibly() throws IgniteException
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:
signal()
method for this
Condition
and the current thread happens to be chosen as the
thread to be awakened; or
signalAll()
method for this
Condition
; or
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
Condition
when this method is called. If not, an IllegalMonitorStateException
will be thrown.
awaitUninterruptibly
in interface Condition
IgniteException
- if the node stopped, or
node owning the lock failed in non-failoversafe modelong awaitNanos(long nanosTimeout) throws IgniteInterruptedException, IgniteException
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:
signal()
method for this
Condition
and the current thread happens to be chosen as the
thread to be awakened; or
signalAll()
method for this
Condition
; or
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:
IgniteInterruptedException
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 method returns an estimate of the number of nanoseconds
remaining to wait given the supplied nanosTimeout
value 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
Condition
when this method is called. If not, an IllegalMonitorStateException
will be thrown.
awaitNanos
in interface Condition
nanosTimeout
- the maximum time to wait, in nanosecondsnanosTimeout
value 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.IgniteInterruptedException
- if the current thread is interruptedIgniteException
- if the node stopped, or
node owning the lock failed in non-failoversafe modeboolean await(long time, TimeUnit unit) throws IgniteInterruptedException, IgniteException
awaitNanos(unit.toNanos(time)) > 0
await
in interface Condition
time
- the maximum time to waitunit
- the time unit of the time
argumentfalse
if the waiting time detectably elapsed
before return from the method, else true
IgniteInterruptedException
- if the current thread is interruptedIgniteException
- if the node stopped, or
node owning the lock failed in non-failoversafe modeboolean awaitUntil(Date deadline) throws IgniteInterruptedException, IgniteException
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:
signal()
method for this
Condition
and the current thread happens to be chosen as the
thread to be awakened; or
signalAll()
method for this
Condition
; or
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:
IgniteInterruptedException
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:
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
Condition
when this method is called. If not, an IllegalMonitorStateException
will be thrown.
awaitUntil
in interface Condition
deadline
- the absolute time to wait untilfalse
if the deadline has elapsed upon return, else
true
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 modevoid signal() throws IgniteException
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
Condition
when this method is called. If not, an IllegalMonitorStateException
will be thrown.
signal
in interface Condition
IgniteException
- if node is stopped or
node owning the lock failed in non-failoversafe modevoid signalAll() throws IgniteException
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
Condition
when this method is called. If not, an IllegalMonitorStateException
will be thrown.
signalAll
in interface Condition
IgniteException
- if node is stopped or
node owning the lock failed in non-failoversafe mode
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023