public abstract class AsynchronousListenerBus<L,E> extends Object implements ListenerBus<L,E>
Until start()
is called, all posted events are only buffered. Only after this listener bus
has started will events be actually propagated to all attached listeners. This listener bus
is stopped when stop()
is called, and it will drop further events after stopping.
Constructor and Description |
---|
AsynchronousListenerBus(String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
listenerThreadIsAlive()
For testing only.
|
abstract void |
onDropEvent(E event)
If the event queue exceeds its capacity, the new events will be dropped.
|
void |
post(E event) |
void |
start()
Start sending events to attached listeners.
|
void |
stop()
Stop the listener bus.
|
boolean |
waitUntilEmpty(int timeoutMillis)
For testing only.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, listeners, onPostEvent, postToAll
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public void start()
This first sends out all buffered events posted before this listener bus has started, then listens for any additional events asynchronously while the listener bus is still running. This should only be called once.
public void post(E event)
public boolean waitUntilEmpty(int timeoutMillis)
public boolean listenerThreadIsAlive()
public void stop()
public abstract void onDropEvent(E event)
Note: onDropEvent
can be called in any thread.