public class TraceableDelegatingDispatcher extends java.lang.Object implements Dispatcher
Dispatcher that traces activity through it.| Constructor and Description |
|---|
TraceableDelegatingDispatcher(Dispatcher delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
alive()
Determine whether this
Resource can be used. |
boolean |
awaitAndShutdown()
Block until all submitted tasks have completed, then do a normal
Resource.shutdown(). |
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Block until all submitted tasks have completed, then do a normal
Resource.shutdown(). |
long |
backlogSize()
Request the capacity for the underlying shared state structure.
|
<E> void |
dispatch(E event,
Consumer<E> consumer,
Consumer<java.lang.Throwable> errorConsumer)
Instruct the
Dispatcher to dispatch the data. |
void |
execute(java.lang.Runnable command) |
void |
forceShutdown()
Shutdown this
Resource, forcibly halting any work currently executing and discarding any tasks that
have not yet been executed. |
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.
|
void |
shutdown()
Shutdown this active
Resource such that it can no longer be used. |
boolean |
supportsOrdering()
Inspect if the dispatcher supports ordered dispatching:
Single threaded dispatchers naturally preserve event ordering on dispatch.
|
<E> void |
tryDispatch(E event,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
Instruct the
Dispatcher to dispatch the data. |
public TraceableDelegatingDispatcher(Dispatcher delegate)
public boolean alive()
ResourceResource can be used.public boolean awaitAndShutdown()
ResourceResource.shutdown().awaitAndShutdown in interface Resourcepublic boolean awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
ResourceResource.shutdown().awaitAndShutdown in interface Resourcepublic void shutdown()
ResourceResource such that it can no longer be used. If the resource carries any work,
it will wait (but NOT blocking the caller) for all the remaining tasks to perform before closing the resource.public void forceShutdown()
ResourceResource, forcibly halting any work currently executing and discarding any tasks that
have not yet been executed.forceShutdown in interface Resourcepublic <E> void tryDispatch(E event,
Consumer<E> eventConsumer,
Consumer<java.lang.Throwable> errorConsumer)
DispatcherDispatcher 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.tryDispatch in interface DispatcherE - type of the eventevent - The eventeventConsumer - The consumer that is driven if dispatch succeedserrorConsumer - The consumer that is invoked if dispatch fails. May be nullpublic <E> void dispatch(E event,
Consumer<E> consumer,
Consumer<java.lang.Throwable> errorConsumer)
DispatcherDispatcher to dispatch the data. The event Consumer
will receive the event. In the event of an error during dispatching, the errorConsumer will be called.dispatch in interface DispatcherE - type of the eventevent - The eventconsumer - The consumer that is driven if dispatch succeedserrorConsumer - The consumer that is invoked if dispatch fails. May be nullpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorpublic boolean supportsOrdering()
DispatchersupportsOrdering in interface Dispatcherpublic long remainingSlots()
DispatcherRingBufferDispatcher will return
RingBuffer.remainingCapacity().
remainingSlots in interface Dispatcherpublic long backlogSize()
DispatcherRingBufferDispatcher will return
RingBuffer.getBufferSize().
backlogSize in interface Dispatcherpublic boolean inContext()
DispatcherinContext in interface Dispatcher