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
public class SingleWaiterMultiNotifier extends Object implements Notifier
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: theNotifier.await()
method is analogous to an imaginary "take all" variant of theBlockingQueue.take()
method, and thesignal()
method is analogous toBlockingQueue.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
-
-
Constructor Summary
Constructors Constructor Description SingleWaiterMultiNotifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
-
-
Field Detail
-
m_oState
protected volatile Object m_oState
The signaling state, null for unsignaled, this for signaled, or a thread for the single awaiting thread
-
-
Method Detail
-
await
public void await(long cMillis) throws InterruptedException
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.
-
getWaitingThread
public Thread getWaitingThread()
Return the thread which is waiting on this notifier.- Returns:
- the waiting thread or null
-
signalInternal
protected Thread 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.
-
-