Interface WaitQueue.Signal

  • All Superinterfaces:
    Awaitable, Condition
    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.
    • 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 isSignalled()
        Returns:
        true if isSignalled()
      • 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