public class ThreadPoolExecutorDispatcher extends MultiThreadDispatcher
Dispatcher that uses a ThreadPoolExecutor with an unbounded queue to dispatch events.MultiThreadDispatcher.MultiThreadTaskAbstractLifecycleDispatcher.Taskcontext, DEFAULT_BUFFER_SIZE| Constructor and Description |
|---|
ThreadPoolExecutorDispatcher(int poolSize,
int backlog)
Creates a new ThreadPoolExecutorDispatcher with the given poolSize and backlog.
|
ThreadPoolExecutorDispatcher(int backlog,
int poolSize,
java.util.concurrent.ExecutorService executor)
Create a new ThreadPoolTaskExecutor with the given backlog and
ExecutorService. |
ThreadPoolExecutorDispatcher(int poolSize,
int backlog,
java.lang.String threadName)
Create a new ThreadPoolExecutorDispatcher with the given size, backlog, name, and
RejectedExecutionHandler. |
ThreadPoolExecutorDispatcher(int poolSize,
int backlog,
java.lang.String threadName,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Create a new ThreadPoolExecutorDispatcher with the given size, backlog, name, and
RejectedExecutionHandler. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Block until all submitted tasks have completed, then do a normal
Resource.shutdown(). |
protected void |
execute(AbstractLifecycleDispatcher.Task task) |
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. |
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. |
allocateRecursiveTask, allocateTask, backlogSize, poolSize, scheduleLater, supportsOrdering, tryAllocateTaskalive, awaitAndShutdown, dispatch, getContext, inContext, route, toString, tryDispatchpublic ThreadPoolExecutorDispatcher(int poolSize,
int backlog)
RejectedExecutionHandler is created which runs the submitted Runnable in the calling thread. To change this behavior, specify your own.poolSize - the pool sizebacklog - the backlog sizepublic ThreadPoolExecutorDispatcher(int poolSize,
int backlog,
java.lang.String threadName)
RejectedExecutionHandler.poolSize - the pool sizebacklog - the backlog sizethreadName - the name prefix to use when creating threadspublic ThreadPoolExecutorDispatcher(int poolSize,
int backlog,
java.lang.String threadName,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
RejectedExecutionHandler.poolSize - the pool sizebacklog - the backlog sizethreadName - the name prefix to use when creating threadsrejectedExecutionHandler - the RejectedExecutionHandler to use when jobs can't be submitted to the thread poolpublic ThreadPoolExecutorDispatcher(int backlog,
int poolSize,
java.util.concurrent.ExecutorService executor)
ExecutorService.backlog - the task backlogpoolSize - the number of threadsexecutor - the executor to use to execute taskspublic boolean awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
ResourceResource.shutdown().public 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 long remainingSlots()
DispatcherRingBufferDispatcher will return
RingBuffer.remainingCapacity().
protected void execute(AbstractLifecycleDispatcher.Task task)
execute in class AbstractLifecycleDispatcherpublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorexecute in class AbstractLifecycleDispatcher