Package com.oracle.coherence.common.base
Class SingleWaiterMultiNotifier
java.lang.Object
com.oracle.coherence.common.base.SingleWaiterMultiNotifier
- All Implemented Interfaces:
Notifier
- Direct Known Subclasses:
SingleWaiterCooperativeNotifier
A Condition-like object, used by a single thread to block for a
notification, and optimized for many concurrent notifications by other
threads. Basically, this is a blocking queue without any state to
actually enqueue: the
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.
- Author:
- cp/mf 2010-06-15
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
await
(long cMillis) Wait for a notification.protected void
Consume the signal.Return the thread which is waiting on this notifier.void
signal()
Notifies the waiting thread(s), waking them up if awaiting.protected Thread
Signal the notifier returning any thread which needs to be unparked.toString()
-
Field Details
-
m_oState
The signaling state, null for unsignaled, this for signaled, or a thread for the single awaiting thread
-
-
Constructor Details
-
SingleWaiterMultiNotifier
public SingleWaiterMultiNotifier()
-
-
Method Details
-
await
Description copied from interface:Notifier
Wait for a notification. Note that spurious wake-ups are possible.- Specified by:
await
in interfaceNotifier
- Parameters:
cMillis
- the maximum wait time in milliseconds, or zero for indefinite- Throws:
InterruptedException
- if the calling thread is interrupted while it is waiting
-
signal
public void signal()Description copied from interface:Notifier
Notifies the waiting thread(s), waking them up if awaiting. -
toString
-
getWaitingThread
Return the thread which is waiting on this notifier.- Returns:
- the waiting thread or null
-
signalInternal
Signal the notifier returning any thread which needs to be unparked.- Returns:
- a the thread if any which needs to be unparked.
-
consumeSignal
protected void consumeSignal()Consume the signal.
-