Package com.oracle.coherence.common.base
Class SingleWaiterCooperativeNotifier
- java.lang.Object
- 
- com.oracle.coherence.common.base.SingleWaiterMultiNotifier
- 
- com.oracle.coherence.common.base.SingleWaiterCooperativeNotifier
 
 
- 
- All Implemented Interfaces:
- Notifier
 
 public class SingleWaiterCooperativeNotifier extends SingleWaiterMultiNotifier SingleWaiterCooperativeNotifier is an extension of the SingleWaiterMultiNotifier which attempts to offload potentially expensive "notification" work from signaling threads onto the waiting threads. This notifier is beneficial when there are few signaling threads, but potentially many waiting threads, each waiting on their own notifier.Unlike the standard Notifier usage, a signaling thread must at some point invoke the static flush()method, orawait(long)on any SingleWaiterCooperativeNotifier to ensure that all deferred signals are processed.- Author:
- mf 2014.03.12
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Threadm_threadAwaitThe waiting thread, or null.protected static bytes_cSignalAn intentionally non-volatile signal counter to ensure periodic flushes.- 
Fields inherited from class com.oracle.coherence.common.base.SingleWaiterMultiNotifierm_oState
 
- 
 - 
Constructor SummaryConstructors Constructor Description SingleWaiterCooperativeNotifier()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait(long cMillis)Wait for a notification.protected voidconsumeSignal()Consume the signal.static voidflush()Ensure that any deferred signals will be processed.protected static voidflush(int cWake, SingleWaiterCooperativeNotifier self)Ensure that any deferred signals will be processed.voidsignal()Notifies the waiting thread(s), waking them up if awaiting.StringtoString()- 
Methods inherited from class com.oracle.coherence.common.base.SingleWaiterMultiNotifiergetWaitingThread, signalInternal
 
- 
 
- 
- 
- 
Field Detail- 
m_threadAwaitprotected Thread m_threadAwait The waiting thread, or null. Visibility ensured via super.m_oState writes.
 - 
s_cSignalprotected static byte s_cSignal An intentionally non-volatile signal counter to ensure periodic flushes. byte is used to allow for auto-flush on every 256 signals (rollover)
 
- 
 - 
Method Detail- 
flushpublic static void flush() Ensure that any deferred signals will be processed.Note it is more advantageous if the calling thread's natural idle point is to sit in await(long), in which case calling this method is not required.
 - 
awaitpublic void await(long cMillis) throws InterruptedExceptionDescription copied from interface:NotifierWait for a notification. Note that spurious wake-ups are possible.- Specified by:
- awaitin interface- Notifier
- Overrides:
- awaitin class- SingleWaiterMultiNotifier
- Parameters:
- cMillis- the maximum wait time in milliseconds, or zero for indefinite
- Throws:
- InterruptedException- if the calling thread is interrupted while it is waiting
 
 - 
signalpublic void signal() Description copied from interface:NotifierNotifies the waiting thread(s), waking them up if awaiting.- Specified by:
- signalin interface- Notifier
- Overrides:
- signalin class- SingleWaiterMultiNotifier
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- SingleWaiterMultiNotifier
 
 - 
flushprotected static void flush(int cWake, SingleWaiterCooperativeNotifier self)Ensure that any deferred signals will be processed.- Parameters:
- cWake- the number of deferrals to signal on the calling thread
- self- the waiting notifier which is flushing, or null
 
 - 
consumeSignalprotected void consumeSignal() Description copied from class:SingleWaiterMultiNotifierConsume the signal.- Overrides:
- consumeSignalin class- SingleWaiterMultiNotifier
 
 
- 
 
-