public abstract class ConcurrentNotifier extends Object implements Notifier
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.
Unlike the SingleWaiterMultiNotifier, this notifier implementation requires
the notion of a ready check. When the notifier is ready then a call
to await because a no-op. An example ready check for a notifier based queue removal
would be !queue.isEmpty();
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ConcurrentNotifier.Link
A link in a stack of waiting threads.
|
| Modifier and Type | Field and Description |
|---|---|
protected Object |
m_oWaitHead
The head of a stack of waiting threads.
|
| Constructor and Description |
|---|
ConcurrentNotifier() |
| Modifier and Type | Method and Description |
|---|---|
void |
await(long cMillis)
Wait for a notification.
|
protected abstract boolean |
isReady()
Return true if the notifier is ready, i.e. threads entering await cant return without blocking.
|
protected ConcurrentNotifier.Link |
makeSelfLink(Thread threadThis,
long lBitThis,
Object oHead)
Make a link for the calling thread, checking if one already exists for this notifier.
|
protected void |
park(long cMillis)
Block the calling thread if the notifier is not ready.
|
void |
signal()
Notifies the waiting thread(s), waking them up if awaiting.
|
protected void |
signalInternal()
Full version of signal.
|
protected volatile Object m_oWaitHead
public void await(long cMillis)
throws InterruptedException
Notifierawait in interface NotifiercMillis - the maximum wait time in milliseconds, or zero for indefiniteInterruptedException - if the calling thread is interrupted
while it is waitingpublic void signal()
Notifierprotected void signalInternal()
protected void park(long cMillis)
throws InterruptedException
cMillis - the time to block forInterruptedException - if the calling thread is interruptedprotected ConcurrentNotifier.Link makeSelfLink(Thread threadThis, long lBitThis, Object oHead)
threadThis - the calling threadlBitThis - this thread's contribution to the bloom filteroHead - the current headprotected abstract boolean isReady()