public interface Dispatcher
extends java.util.concurrent.Executor
| Modifier and Type | Method and Description |
|---|---|
boolean |
alive()
Determine whether this
Dispatcher can be used for dispatching. |
boolean |
awaitAndShutdown()
Block until all submitted tasks have completed, then do a normal
shutdown(). |
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Block until all submitted tasks have completed, then do a normal
shutdown(). |
<E extends Event<?>> |
dispatch(E event,
EventRouter eventRouter,
Consumer<E> consumer,
Consumer<java.lang.Throwable> errorConsumer)
|
<E extends Event<?>> |
dispatch(java.lang.Object key,
E event,
Registry<Consumer<? extends Event<?>>> consumerRegistry,
Consumer<java.lang.Throwable> errorConsumer,
EventRouter eventRouter,
Consumer<E> completionConsumer)
Instruct the
Dispatcher to dispatch the event that has the given key. |
void |
halt()
Shutdown this
Dispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected. |
void |
shutdown()
Shutdown this
Dispatcher such that it can no longer be used. |
boolean alive()
Dispatcher can be used for dispatching.Dispatcher is alive and can be used, false otherwise.boolean awaitAndShutdown()
shutdown().boolean awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
shutdown().void shutdown()
Dispatcher such that it can no longer be used.void halt()
Dispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected.<E extends Event<?>> void dispatch(java.lang.Object key, E event, Registry<Consumer<? extends Event<?>>> consumerRegistry, Consumer<java.lang.Throwable> errorConsumer, EventRouter eventRouter, Consumer<E> completionConsumer)
Dispatcher to dispatch the event that has the given key. The Consumers
that will receive the event are selected from the consumerRegistry, and the event is routed to them using
the eventRouter. In the event of an error during dispatching, the errorConsumer will be called. In
the event of successful dispatching, the completionConsumer will be called.E - type of the eventkey - The key associated with the eventevent - The eventconsumerRegistry - The registry from which consumer's are selectederrorConsumer - The consumer that is invoked if dispatch fails. May be nulleventRouter - Used to route the event to the selected consumerscompletionConsumer - The consumer that is driven if dispatch succeeds May be nulljava.lang.IllegalStateException - If the Dispatcher is not alive<E extends Event<?>> void dispatch(E event, EventRouter eventRouter, Consumer<E> consumer, Consumer<java.lang.Throwable> errorConsumer)
Dispatcher to dispatch the given Event using the given Consumer. This optimized
route bypasses all selection and routing so provides a significant throughput boost. If an error occurs, the given
errorConsumer will be invoked.E - type of the eventevent - the eventeventRouter - invokes the Consumer in the correct threaderrorConsumer - consumer to invoke if dispatch fails (may be null)java.lang.IllegalStateException - If the Dispatcher is not alive