public class WrappedExecutorPlus extends java.lang.Object implements ExecutorPlus
ExecutorPlus.MaximumPoolSizeListener
Modifier and Type | Field and Description |
---|---|
protected ExecutorPlus |
executor |
Constructor and Description |
---|
WrappedExecutorPlus(ExecutorPlus executor) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
execute(java.lang.Runnable task) |
void |
execute(WithResources withResources,
java.lang.Runnable task)
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() |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
maybeExecuteImmediately(java.lang.Runnable task)
MAY execute
task immediately, if the calling thread is permitted to do so. |
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> task)
Overrides
ExecutorService.submit(Callable) to return a Cassandra Future |
Future<?> |
submit(java.lang.Runnable task)
Overrides
ExecutorService.submit(Runnable) to return a Cassandra Future |
<T> Future<T> |
submit(java.lang.Runnable task,
T result)
Overrides
ExecutorService.submit(Runnable, Object) to return a Cassandra Future |
<T> Future<T> |
submit(WithResources withResources,
java.util.concurrent.Callable<T> task)
Invoke
task , returning a future representing this computation. |
Future<?> |
submit(WithResources withResources,
java.lang.Runnable task)
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 task,
T result)
Invoke
task , returning a future yielding result if successful,
or the abnormal termination of task otherwise. |
protected final ExecutorPlus executor
public WrappedExecutorPlus(ExecutorPlus executor)
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(WithResources withResources, java.lang.Runnable task)
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
task
- the task to executepublic <T> Future<T> submit(WithResources withResources, java.util.concurrent.Callable<T> task)
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
task
- the task to executepublic <T> Future<T> submit(WithResources withResources, java.lang.Runnable task, 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
task
- the task to executeresult
- the result if successfulpublic Future<?> submit(WithResources withResources, java.lang.Runnable task)
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
task
- the task to executepublic boolean inExecutor()
inExecutor
in interface ExecutorPlus
public <T> Future<T> submit(java.util.concurrent.Callable<T> task)
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(java.lang.Runnable task, T result)
ExecutorPlus
ExecutorService.submit(Runnable, Object)
to return a Cassandra Future
submit
in interface java.util.concurrent.ExecutorService
submit
in interface ExecutorPlus
public Future<?> submit(java.lang.Runnable task)
ExecutorPlus
ExecutorService.submit(Runnable)
to return a Cassandra Future
submit
in interface java.util.concurrent.ExecutorService
submit
in interface ExecutorPlus
public int getActiveTaskCount()
ResizableThreadPool
getActiveTaskCount
in interface ResizableThreadPool
public long getCompletedTaskCount()
ResizableThreadPool
getCompletedTaskCount
in interface ResizableThreadPool
public int getPendingTaskCount()
ResizableThreadPool
getPendingTaskCount
in interface ResizableThreadPool
public int getMaxTasksQueued()
getMaxTasksQueued
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
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException
invokeAll
in interface java.util.concurrent.ExecutorService
invokeAll
in interface ExecutorPlus
java.lang.InterruptedException
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
invokeAll
in interface java.util.concurrent.ExecutorService
invokeAll
in interface ExecutorPlus
java.lang.InterruptedException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
invokeAny
in interface java.util.concurrent.ExecutorService
invokeAny
in interface ExecutorPlus
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
invokeAny
in interface java.util.concurrent.ExecutorService
invokeAny
in interface ExecutorPlus
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
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 void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
Copyright © 2009- The Apache Software Foundation