public abstract class AbstractLifecycleDispatcher extends java.lang.Object implements Dispatcher
Dispatcher that has a lifecycle.| Modifier and Type | Class and Description |
|---|---|
class |
AbstractLifecycleDispatcher.Task |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLifecycleDispatcher() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToTailRecursionPile(AbstractLifecycleDispatcher.Task task) |
boolean |
alive()
Determine whether this
Dispatcher can be used for dispatching. |
protected abstract AbstractLifecycleDispatcher.Task |
allocateRecursiveTask() |
protected abstract AbstractLifecycleDispatcher.Task |
allocateTask() |
boolean |
awaitAndShutdown()
Block until all submitted tasks have completed, then do a normal
Dispatcher.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. |
protected abstract void |
execute(AbstractLifecycleDispatcher.Task task) |
void |
execute(java.lang.Runnable command) |
protected java.lang.ClassLoader |
getContext() |
void |
halt()
Shutdown this
Dispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected. |
protected boolean |
isInContext()
Dispatchers can be traced through a
contextClassLoader to let producers adapting their dispatching
strategy |
protected static void |
route(AbstractLifecycleDispatcher.Task task) |
void |
shutdown()
Shutdown this
Dispatcher such that it can no longer be used. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitawaitAndShutdownprotected static void route(AbstractLifecycleDispatcher.Task task)
public boolean alive()
DispatcherDispatcher can be used for dispatching.alive in interface DispatcherDispatcher is alive and can be used, false otherwise.public boolean awaitAndShutdown()
DispatcherDispatcher.shutdown().awaitAndShutdown in interface Dispatcherpublic void shutdown()
DispatcherDispatcher such that it can no longer be used.shutdown in interface Dispatcherpublic void halt()
DispatcherDispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected.halt in interface Dispatcherprotected final boolean isInContext()
contextClassLoader to let producers adapting their dispatching
strategyprotected final java.lang.ClassLoader getContext()
public final <E extends Event<?>> void dispatch(E event, EventRouter eventRouter, Consumer<E> consumer, Consumer<java.lang.Throwable> errorConsumer)
DispatcherDispatcher 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.dispatch in interface DispatcherE - type of the eventevent - the eventeventRouter - invokes the Consumer in the correct threaderrorConsumer - consumer to invoke if dispatch fails (may be null)public <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)
DispatcherDispatcher 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.dispatch in interface DispatcherE - 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 nullpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorprotected void addToTailRecursionPile(AbstractLifecycleDispatcher.Task task)
protected abstract AbstractLifecycleDispatcher.Task allocateRecursiveTask()
protected abstract AbstractLifecycleDispatcher.Task allocateTask()
protected abstract void execute(AbstractLifecycleDispatcher.Task task)