public interface Dispatcher extends java.util.concurrent.Executor, Resource
Dispatcher is used to dispatch(Object, Consumer, Consumer)
dispatch} data to Consumers. The details of how the dispatching is performed, for example on the
same thread or using a different thread, are determined by the implementation.| Modifier and Type | Method and Description |
|---|---|
long |
backlogSize()
Request the capacity for the underlying shared state structure.
|
<E> void |
dispatch(E data,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
Instruct the
Dispatcher to dispatch the data. |
boolean |
inContext()
A dispatcher context can be bound to the thread(s) it runs on.
|
long |
remainingSlots()
Request the remaining capacity for the underlying shared state structure.
|
boolean |
supportsOrdering()
Inspect if the dispatcher supports ordered dispatching:
Single threaded dispatchers naturally preserve event ordering on dispatch.
|
<E> void |
tryDispatch(E data,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
Instruct the
Dispatcher to dispatch the data. |
alive, awaitAndShutdown, awaitAndShutdown, forceShutdown, shutdown<E> void dispatch(E data,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
Dispatcher to dispatch the data. The event Consumer
will receive the event. In the event of an error during dispatching, the errorConsumer will be called.E - type of the eventdata - The eventeventConsumer - The consumer that is driven if dispatch succeedserrorConsumer - The consumer that is invoked if dispatch fails. May be nulljava.lang.IllegalStateException - If the Dispatcher is not alive<E> void tryDispatch(E data,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
throws InsufficientCapacityException
Dispatcher to dispatch the data.
If the dispatcher doesn't have enough capacity and might block on the next produced event,
The event Consumer
will receive the event. In the event of an error during dispatching, the errorConsumer will be called.E - type of the eventdata - The eventeventConsumer - The consumer that is driven if dispatch succeedserrorConsumer - The consumer that is invoked if dispatch fails. May be nulljava.lang.IllegalStateException - If the Dispatcher is not aliveInsufficientCapacityExceptionlong remainingSlots()
RingBufferDispatcher will return
RingBuffer.remainingCapacity().
long backlogSize()
RingBufferDispatcher will return
RingBuffer.getBufferSize().
boolean supportsOrdering()
boolean inContext()