public final class MpscDispatcher extends SingleThreadDispatcher
Dispatcher
that uses a MpscLinkedQueue
to
queue tasks to execute.SingleThreadDispatcher.SingleThreadTask
AbstractLifecycleDispatcher.Task
backlog, tailRecurseSeq, tailRecursionPile, tailRecursionPileSize
context
Constructor and Description |
---|
MpscDispatcher(String name)
Creates a new
MpscDispatcher with the given name . |
MpscDispatcher(String name,
int bufferSize)
Creates a new
MpscDispatcher with the given name . |
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() . |
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. |
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, expandTailRecursionPile, getTailRecursionPileSize, supportsOrdering
alive, awaitAndShutdown, dispatch, execute, getContext, inContext, route, scheduleLater, toString, tryDispatch
public MpscDispatcher(String name)
MpscDispatcher
with the given name
. It will use a MpscLinkedQueue and a virtual capacity of 1024 slots.name
- The name of the dispatcher.public MpscDispatcher(String name, int bufferSize)
MpscDispatcher
with the given name
. It will use a MpscLinkedQueue and a virtual capacity of {code bufferSize}name
- The name of the dispatcherbufferSize
- The size to configure the ring buffer withpublic boolean awaitAndShutdown(long timeout, TimeUnit timeUnit)
Resource
Resource.shutdown()
.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 long remainingSlots()
Dispatcher
RingBufferDispatcher
will return
RingBuffer.remainingCapacity()
.
protected AbstractLifecycleDispatcher.Task tryAllocateTask() throws InsufficientCapacityException
tryAllocateTask
in class AbstractLifecycleDispatcher
InsufficientCapacityException
protected AbstractLifecycleDispatcher.Task allocateTask()
allocateTask
in class SingleThreadDispatcher
protected void execute(AbstractLifecycleDispatcher.Task task)
execute
in class AbstractLifecycleDispatcher
Copyright © 2017. All rights reserved.