abstract class Dispatcher
extends java.lang.Object
Note: The dispatcher is orthogonal to the subscriber's Executor
. The dispatcher
controls the order in which events are dispatched, while the executor controls how (i.e. on which
thread) the subscriber is actually called when an event is dispatched to it.
Modifier and Type | Class and Description |
---|---|
private static class |
Dispatcher.ImmediateDispatcher
Implementation of
immediate() . |
private static class |
Dispatcher.LegacyAsyncDispatcher
Implementation of a
legacyAsync() dispatcher. |
private static class |
Dispatcher.PerThreadQueuedDispatcher
Implementation of a
perThreadDispatchQueue() dispatcher. |
Constructor and Description |
---|
Dispatcher() |
Modifier and Type | Method and Description |
---|---|
(package private) abstract void |
dispatch(java.lang.Object event,
java.util.Iterator<Subscriber> subscribers)
Dispatches the given
event to the given subscribers . |
(package private) static Dispatcher |
immediate()
Returns a dispatcher that dispatches events to subscribers immediately as they're posted
without using an intermediate queue to change the dispatch order.
|
(package private) static Dispatcher |
legacyAsync()
Returns a dispatcher that queues events that are posted in a single global queue.
|
(package private) static Dispatcher |
perThreadDispatchQueue()
Returns a dispatcher that queues events that are posted reentrantly on a thread that is already
dispatching an event, guaranteeing that all events posted on a single thread are dispatched to
all subscribers in the order they are posted.
|
static Dispatcher perThreadDispatchQueue()
When all subscribers are dispatched to using a direct executor (which dispatches on the same thread that posts the event), this yields a breadth-first dispatch order on each thread. That is, all subscribers to a single event A will be called before any subscribers to any events B and C that are posted to the event bus by the subscribers to A.
static Dispatcher legacyAsync()
static Dispatcher immediate()
abstract void dispatch(java.lang.Object event, java.util.Iterator<Subscriber> subscribers)
event
to the given subscribers
.