Interface WaitQueue.Signal
-
- All Known Implementing Classes:
WaitQueue.Standard.AbstractSignal
- Enclosing interface:
- WaitQueue
public static interface WaitQueue.Signal extends Condition
A Signal is a one-time-use mechanism for a thread to wait for notification that some condition state has transitioned that it may be interested in (and hence should check if it is). It is potentially transient, i.e. the state can change in the meantime, it only indicates that it should be checked, not necessarily anything about what the expected state should be. Signal implementations should never wake up spuriously, they are always woken up by a signal() or signalAll(). This abstract definition of Signal does not need to be tied to a WaitQueue. Whilst RegisteredSignal is the main building block of Signals, this abstract definition allows us to compose Signals in useful ways. The Signal is 'owned' by the thread that registered itself with WaitQueue(s) to obtain the underlying RegisteredSignal(s); only the owning thread should use a Signal.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Awaitable
Awaitable.AbstractAwaitable, Awaitable.AsyncAwaitable, Awaitable.Defaults, Awaitable.SyncAwaitable
-
Nested classes/interfaces inherited from interface org.apache.cassandra.utils.concurrent.Condition
Condition.Async, Condition.Sync
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Awaitable
await()
Await indefinitely, throwing any interrupt.boolean
awaitUntil(long nanoTimeDeadline)
Await until the deadline (in nanoTime), throwing any interrupt.void
cancel()
Should only be called by the owning thread.boolean
checkAndClear()
atomically: cancels the Signal if !isSet(), or returns true if isSet()boolean
isCancelled()
boolean
isSet()
-
Methods inherited from interface org.apache.cassandra.utils.concurrent.Awaitable
await, awaitThrowUncheckedOnInterrupt, awaitThrowUncheckedOnInterrupt, awaitUninterruptibly, awaitUninterruptibly, awaitUntilThrowUncheckedOnInterrupt, awaitUntilUninterruptibly
-
Methods inherited from interface org.apache.cassandra.utils.concurrent.Condition
isSignalled, signal, signalAll
-
-
-
-
Method Detail
-
isCancelled
boolean isCancelled()
- Returns:
- true if cancelled; once cancelled, must be discarded by the owning thread.
-
isSet
boolean isSet()
- Returns:
- isSignalled() || isCancelled(). Once true, the state is fixed and the Signal should be discarded by the owning thread.
-
checkAndClear
boolean checkAndClear()
atomically: cancels the Signal if !isSet(), or returns true if isSet()- Returns:
- true if isSet()
-
cancel
void cancel()
Should only be called by the owning thread. Indicates the signal can be retired, and if signalled propagates the signal to another waiting thread
-
await
Awaitable await() throws java.lang.InterruptedException
Await indefinitely, throwing any interrupt. No spurious wakeups. Important: the signal can be cancelled if the thread executing await() is interrupted
-
awaitUntil
boolean awaitUntil(long nanoTimeDeadline) throws java.lang.InterruptedException
Await until the deadline (in nanoTime), throwing any interrupt. No spurious wakeups.- Specified by:
awaitUntil
in interfaceAwaitable
- Returns:
- true if we were signalled, false if the deadline elapsed Important: the signal can be cancelled if the thread executing await() is interrupted
- Throws:
java.lang.InterruptedException
- if interrupted
-
-