public class SEPExecutor extends java.lang.Object implements LocalAwareExecutorPlus, SEPExecutorMBean
Modifier and Type | Class and Description |
---|---|
static class |
SEPExecutor.TakeTaskPermitResult |
ExecutorPlus.MaximumPoolSizeListener
Modifier and Type | Field and Description |
---|---|
ThreadPoolMetrics |
metrics |
java.lang.String |
name |
protected java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> |
tasks |
Modifier and Type | Method and Description |
---|---|
protected <T extends java.lang.Runnable> |
addTask(T task) |
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
execute(java.lang.Runnable run) |
void |
execute(WithResources withResources,
java.lang.Runnable run)
Invoke
task . |
int |
getActiveTaskCount()
Returns the approximate number of threads that are actively
executing tasks.
|
long |
getCompletedTaskCount()
Returns the approximate total number of tasks that have
completed execution.
|
int |
getCorePoolSize()
Returns core pool size of thread pool, the minimum
number of workers (where that makes sense for a thread pool,
SEPExecutor does not have a minimum size).
|
int |
getMaximumPoolSize()
Returns maximum pool size of thread pool.
|
int |
getMaxTasksQueued() |
int |
getPendingTaskCount()
Returns the approximate total of tasks waiting to be executed.
|
boolean |
inExecutor() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
maybeExecuteImmediately(java.lang.Runnable task)
MAY execute
task immediately, if the calling thread is permitted to do so. |
protected void |
onCompletion() |
void |
setCorePoolSize(int newCorePoolSize)
Allows user to resize minimum size of the thread pool.
|
void |
setMaximumPoolSize(int newMaximumPoolSize)
Allows user to resize maximum size of the thread pool.
|
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invokeAll, invokeAll, invokeAny, invokeAny
public final java.lang.String name
public final ThreadPoolMetrics metrics
protected final java.util.concurrent.ConcurrentLinkedQueue<java.lang.Runnable> tasks
protected void onCompletion()
public int getMaxTasksQueued()
getMaxTasksQueued
in interface ResizableThreadPool
protected <T extends java.lang.Runnable> T addTask(T task)
public void maybeExecuteImmediately(java.lang.Runnable task)
ExecutorPlus
task
immediately, if the calling thread is permitted to do so.maybeExecuteImmediately
in interface ExecutorPlus
public void execute(java.lang.Runnable run)
execute
in interface java.util.concurrent.Executor
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
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
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
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
public void shutdown()
shutdown
in interface java.util.concurrent.ExecutorService
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in interface java.util.concurrent.ExecutorService
public boolean isShutdown()
isShutdown
in interface java.util.concurrent.ExecutorService
public boolean isTerminated()
isTerminated
in interface java.util.concurrent.ExecutorService
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
awaitTermination
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
public int getPendingTaskCount()
ResizableThreadPool
getPendingTaskCount
in interface ResizableThreadPool
public long getCompletedTaskCount()
ResizableThreadPool
getCompletedTaskCount
in interface ResizableThreadPool
public int getActiveTaskCount()
ResizableThreadPool
getActiveTaskCount
in interface ResizableThreadPool
public int getCorePoolSize()
ResizableThreadPool
getCorePoolSize
in interface ResizableThreadPool
public void setCorePoolSize(int newCorePoolSize)
ResizableThreadPool
setCorePoolSize
in interface ResizableThreadPool
public int getMaximumPoolSize()
ResizableThreadPool
getMaximumPoolSize
in interface ResizableThreadPool
public void setMaximumPoolSize(int newMaximumPoolSize)
ResizableThreadPool
setMaximumPoolSize
in interface ResizableThreadPool
Copyright © 2009- The Apache Software Foundation