public final class WorkQueueDispatcher extends MultiThreadDispatcher implements WaitingMood
Dispatcher
that uses a multi-threaded, multi-producer RingBuffer
to queue tasks
to execute.MultiThreadDispatcher.MultiThreadTask
AbstractLifecycleDispatcher.Task
context, DEFAULT_BUFFER_SIZE
Constructor and Description |
---|
WorkQueueDispatcher(String name,
int poolSize,
int backlog,
Consumer<Throwable> uncaughtExceptionHandler) |
WorkQueueDispatcher(String name,
int poolSize,
int backlog,
Consumer<Throwable> uncaughtExceptionHandler,
com.lmax.disruptor.dsl.ProducerType producerType,
com.lmax.disruptor.WaitStrategy waitStrategy) |
Modifier and Type | Method and Description |
---|---|
protected AbstractLifecycleDispatcher.Task |
allocateTask() |
boolean |
awaitAndShutdown(long timeout,
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, supportsOrdering
alive, awaitAndShutdown, dispatch, execute, getContext, inContext, route, toString, tryDispatch
public WorkQueueDispatcher(String name, int poolSize, int backlog, Consumer<Throwable> uncaughtExceptionHandler)
public boolean awaitAndShutdown(long timeout, TimeUnit timeUnit)
Resource
Resource.shutdown()
.awaitAndShutdown
in interface Resource
public void shutdown()
Resource
Resource
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 Resource
shutdown
in class AbstractLifecycleDispatcher
public void forceShutdown()
Resource
Resource
, forcibly halting any work currently executing and discarding any tasks that
have not yet been executed.forceShutdown
in interface Resource
forceShutdown
in class AbstractLifecycleDispatcher
public void nervous()
WaitingMood
nervous
in interface WaitingMood
public void calm()
WaitingMood
calm
in interface WaitingMood
public long remainingSlots()
Dispatcher
RingBufferDispatcher
will return
RingBuffer.remainingCapacity()
.
remainingSlots
in interface Dispatcher
protected AbstractLifecycleDispatcher.Task allocateTask()
allocateTask
in class MultiThreadDispatcher
protected AbstractLifecycleDispatcher.Task tryAllocateTask() throws InsufficientCapacityException
tryAllocateTask
in class MultiThreadDispatcher
InsufficientCapacityException
protected void execute(AbstractLifecycleDispatcher.Task task)
execute
in class AbstractLifecycleDispatcher
Copyright © 2016. All rights reserved.