public final class WorkQueueDispatcher extends MultiThreadDispatcher implements WaitingMood
Dispatcher that uses a multi-threaded, multi-producer RingBuffer to queue tasks
to execute.MultiThreadDispatcher.MultiThreadTaskAbstractLifecycleDispatcher.Taskcontext, DEFAULT_BUFFER_SIZE| Constructor and Description |
|---|
WorkQueueDispatcher(java.lang.String name,
int poolSize,
int backlog,
Consumer<java.lang.Throwable> uncaughtExceptionHandler) |
WorkQueueDispatcher(java.lang.String name,
int poolSize,
int backlog,
Consumer<java.lang.Throwable> uncaughtExceptionHandler,
reactor.jarjar.com.lmax.disruptor.dsl.ProducerType producerType,
reactor.jarjar.com.lmax.disruptor.WaitStrategy waitStrategy) |
| Modifier and Type | Method and Description |
|---|---|
protected AbstractLifecycleDispatcher.Task |
allocateTask() |
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Block until all submitted tasks have completed, then do a normal
Resource.shutdown(). |
void |
calm()
Turn the mood into eco CPU demand mode to save resources from the underlying component.
|
protected void |
execute(AbstractLifecycleDispatcher.Task task) |
void |
forceShutdown()
Shutdown this
Resource, forcibly halting any work currently executing and discarding any tasks that
have not yet been executed. |
void |
nervous()
Turn the mood into aggressive CPU demand mode to effectively give an an additional resources boost to the underlying
component.
|
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. |
protected AbstractLifecycleDispatcher.Task |
tryAllocateTask() |
allocateRecursiveTask, backlogSize, poolSize, scheduleLater, supportsOrderingalive, awaitAndShutdown, dispatch, execute, getContext, inContext, route, toString, tryDispatchpublic WorkQueueDispatcher(java.lang.String name,
int poolSize,
int backlog,
Consumer<java.lang.Throwable> uncaughtExceptionHandler)
public WorkQueueDispatcher(java.lang.String name,
int poolSize,
int backlog,
Consumer<java.lang.Throwable> uncaughtExceptionHandler,
reactor.jarjar.com.lmax.disruptor.dsl.ProducerType producerType,
reactor.jarjar.com.lmax.disruptor.WaitStrategy waitStrategy)
public 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.shutdown in interface Resourceshutdown in class AbstractLifecycleDispatcherpublic void forceShutdown()
ResourceResource, forcibly halting any work currently executing and discarding any tasks that
have not yet been executed.forceShutdown in interface ResourceforceShutdown in class AbstractLifecycleDispatcherpublic void nervous()
WaitingMoodnervous in interface WaitingMoodpublic void calm()
WaitingMoodcalm in interface WaitingMoodpublic long remainingSlots()
DispatcherRingBufferDispatcher will return
RingBuffer.remainingCapacity().
remainingSlots in interface Dispatcherprotected AbstractLifecycleDispatcher.Task allocateTask()
allocateTask in class MultiThreadDispatcherprotected AbstractLifecycleDispatcher.Task tryAllocateTask() throws InsufficientCapacityException
tryAllocateTask in class MultiThreadDispatcherInsufficientCapacityExceptionprotected void execute(AbstractLifecycleDispatcher.Task task)
execute in class AbstractLifecycleDispatcher