public class SingleWaiterMultiNotifier extends Object implements Notifier
Notifier.await()
method
is analogous to an imaginary "take all" variant of the
BlockingQueue.take()
method, and the
signal()
method is analogous to
BlockingQueue.put()
.
Note that no synchronization is needed to use this class; i.e. clients
must not synchronize on this class prior to calling await()
or
signal()
, nor should the use any of the primitive wait()
or notify()
methods.
Since SingleWaiterMultiNotifier is only usable by a single waiting thread it is does not require an external readiness check, as signaling can record that state.
Modifier and Type | Field and Description |
---|---|
protected Object |
m_oState
The signaling state, null for unsignaled, this for signaled, or a thread for the single awaiting thread
|
Constructor and Description |
---|
SingleWaiterMultiNotifier() |
Modifier and Type | Method and Description |
---|---|
void |
await(long cMillis)
Wait for a notification.
|
protected void |
consumeSignal()
Consume the signal.
|
Thread |
getWaitingThread()
Return the thread which is waiting on this notifier.
|
void |
signal()
Notifies the waiting thread(s), waking them up if awaiting.
|
protected Thread |
signalInternal()
Signal the notifier returning any thread which needs to be unparked.
|
String |
toString() |
protected volatile Object m_oState
public void await(long cMillis) throws InterruptedException
Notifier
await
in interface Notifier
cMillis
- the maximum wait time in milliseconds, or zero for indefiniteInterruptedException
- if the calling thread is interrupted
while it is waitingpublic void signal()
Notifier
public Thread getWaitingThread()
protected Thread signalInternal()
protected void consumeSignal()