public class ThreadPoolExecutorPlus extends ThreadPoolExecutorBase implements ExecutorPlus
ThreadPoolExecutorBase
and ThreadPoolExecutorBuilder
. Most Cassandra executors should use or extend this.
This class' addition is to abstract the semantics of task encapsulation to handle
exceptions and ExecutorLocals
. See TaskFactory
for more detail.java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
ExecutorPlus.MaximumPoolSizeListener
blockingExecutionHandler
Modifier and Type | Method and Description |
---|---|
void |
execute(java.lang.Runnable run) |
void |
execute(WithResources withResources,
java.lang.Runnable run)
Invoke
task . |
int |
getMaxTasksQueued() |
boolean |
inExecutor() |
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.util.concurrent.Callable<T> callable) |
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.lang.Runnable runnable,
T value) |
<T> Future<T> |
submit(java.util.concurrent.Callable<T> call)
Overrides
ExecutorService.submit(Callable) to return a Cassandra Future |
Future<?> |
submit(java.lang.Runnable run)
Overrides
ExecutorService.submit(Runnable) to return a Cassandra Future |
<T> Future<T> |
submit(java.lang.Runnable run,
T result)
Overrides
ExecutorService.submit(Runnable, Object) to return a Cassandra Future |
<T> Future<T> |
submit(WithResources withResources,
java.util.concurrent.Callable<T> call)
Invoke
task , returning a future representing this computation. |
Future<?> |
submit(WithResources withResources,
java.lang.Runnable run)
Invoke
task , returning a future yielding null if successful,
or the abnormal termination of task otherwise. |
<T> Future<T> |
submit(WithResources withResources,
java.lang.Runnable run,
T result)
Invoke
task , returning a future yielding result if successful,
or the abnormal termination of task otherwise. |
getActiveTaskCount, getCoreThreads, getMaximumThreads, getPendingTaskCount, getThreadFactory, onShutdown, onShutdown, setCoreThreads, setMaximumThreads, shutdown, shutdownNow, terminated, toString
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory
invokeAll, invokeAll, invokeAny, invokeAny
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
invokeAll, invokeAll, invokeAny, invokeAny, maybeExecuteImmediately
awaitTermination, isShutdown, isTerminated, shutdown, shutdownNow
getActiveTaskCount, getCompletedTaskCount, getCorePoolSize, getMaximumPoolSize, getPendingTaskCount, setCorePoolSize, setMaximumPoolSize
public void execute(java.lang.Runnable run)
execute
in interface java.util.concurrent.Executor
execute
in class java.util.concurrent.ThreadPoolExecutor
public void execute(WithResources withResources, java.lang.Runnable run)
ExecutorPlus
task
. The invoking thread will first instantiate the resources provided before
invoking task
, so that thread state may be modified and cleaned up.
The invoking thread will execute something semantically equivlent to:
try (Closeable close = withResources.get())
{
task.run();
}
execute
in interface ExecutorPlus
withResources
- the resources to create and hold while executing task
run
- the task to executepublic Future<?> submit(java.lang.Runnable run)
ExecutorPlus
ExecutorService.submit(Runnable)
to return a Cassandra Future
submit
in interface java.util.concurrent.ExecutorService
submit
in interface ExecutorPlus
submit
in class java.util.concurrent.AbstractExecutorService
public <T> Future<T> submit(java.lang.Runnable run, T result)
ExecutorPlus
ExecutorService.submit(Runnable, Object)
to return a Cassandra Future
submit
in interface java.util.concurrent.ExecutorService
submit
in interface ExecutorPlus
submit
in class java.util.concurrent.AbstractExecutorService
public <T> Future<T> submit(java.util.concurrent.Callable<T> call)
ExecutorPlus
ExecutorService.submit(Callable)
to return a Cassandra Future
submit
in interface java.util.concurrent.ExecutorService
submit
in interface ExecutorPlus
submit
in class java.util.concurrent.AbstractExecutorService
public <T> Future<T> submit(WithResources withResources, java.lang.Runnable run, T result)
ExecutorPlus
task
, returning a future yielding result
if successful,
or the abnormal termination of task
otherwise.
The invoking thread will first instantiate the resources provided before
invoking task
, so that thread state may be modified and cleaned up.
The invoking thread will execute something semantically equivlent to:
try (Closeable close = withResources.get())
{
task.run();
return result;
}
submit
in interface ExecutorPlus
withResources
- the resources to create and hold while executing task
run
- the task to executeresult
- the result if successfulpublic Future<?> submit(WithResources withResources, java.lang.Runnable run)
ExecutorPlus
task
, returning a future yielding null
if successful,
or the abnormal termination of task
otherwise.
The invoking thread will first instantiate the resources provided before
invoking task
, so that thread state may be modified and cleaned up
try (Closeable close = withResources.get())
{
task.run();
return null;
}
submit
in interface ExecutorPlus
withResources
- the resources to create and hold while executing task
run
- the task to executepublic <T> Future<T> submit(WithResources withResources, java.util.concurrent.Callable<T> call)
ExecutorPlus
task
, returning a future representing this computation.
The invoking thread will first instantiate the resources provided before
invoking task
, so that thread state may be modified and cleaned up.
The invoking thread will execute something semantically equivlent to:
try (Closeable close = withResources.get())
{
return task.call();
}
submit
in interface ExecutorPlus
withResources
- the resources to create and hold while executing task
call
- the task to executepublic boolean inExecutor()
inExecutor
in interface ExecutorPlus
protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.lang.Runnable runnable, T value)
newTaskFor
in class java.util.concurrent.AbstractExecutorService
protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor(java.util.concurrent.Callable<T> callable)
newTaskFor
in class java.util.concurrent.AbstractExecutorService
public int getMaxTasksQueued()
getMaxTasksQueued
in interface ResizableThreadPool
Copyright © 2009- The Apache Software Foundation