ES - The internal execution service.public abstract class AbstractExecutorService<ES extends ThreadPoolExecutor> extends Object implements org.openbase.jul.iface.Shutdownable
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_REPORT_RATE
Report rate for the debug mode in milliseconds.
|
static long |
DEFAULT_SHUTDOWN_DELAY
Default shutdown delay in milliseconds.
|
static long |
DEFAULT_SHUTDOWN_TIME
Default shutdown time in milliseconds.
|
static double |
DEFAULT_WARNING_RATIO
The ratio of the threads which can be used until pool overload warnings are periodically printed.
|
protected ES |
executorService
The internally used executor service.
|
protected org.slf4j.Logger |
logger |
static long |
SMART_SHUTDOWN_STATUS_PRINT_RATE
The rate for printing feedback if the shutdown is delayed.
|
static long |
SMART_SHUTDOWN_TIMEOUT
Default shutdown time in milliseconds.
|
| Constructor and Description |
|---|
AbstractExecutorService(ES executorService) |
| Modifier and Type | Method and Description |
|---|---|
static <R> Future<R> |
allOf(Callable<R> resultCallable,
Collection<Future> futureCollection)
Method generates a new futures which represents all futures provided by the futureCollection.
|
static <R> Future<R> |
allOf(Callable resultCallable,
Future... futures) |
static <R> Future<R> |
allOf(Collection<Future> futureCollection) |
static <I,O,R> Future<R> |
allOf(Collection<I> inputList,
org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor,
org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor) |
static <I,R> Future<R> |
allOf(Collection<I> inputList,
org.openbase.jul.iface.Processable<I,Future<R>> taskProcessor) |
static <R> Future<R> |
allOf(ExecutorService executorService,
Callable<R> resultCallable,
Collection<Future> futureCollection)
Method generates a new futures which represents all futures provided by the futureCollection.
|
static <I,O,R> Future<R> |
allOf(ExecutorService executorService,
Collection<I> inputList,
org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor,
org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor) |
static <I,R> Future<R> |
allOf(ExecutorService executorService,
Collection<I> inputList,
org.openbase.jul.iface.Processable<I,Future<Void>> taskProcessor) |
static <O,R> Future<R> |
allOf(ExecutorService executorService,
org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor,
Collection<Future<O>> futureCollection)
Method generates a new futures which represents all futures provided by the futureCollection.
|
static <R> Future<R> |
allOf(ExecutorService executorService,
R returnValue,
Collection<Future> futureCollection) |
static Future<Void> |
allOf(Future... futures) |
static <O,R> Future<R> |
allOf(org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor,
Collection<Future<O>> futureCollection)
Method generates a new futures which represents all futures provided by the futureCollection.If all futures are successfully finished the outer future will be completed with the result provided by the resultProcessor.
|
static <R> Future<R> |
allOf(R returnValue,
Collection<Future> futureCollection) |
static <R> Future<R> |
allOfInclusiveResultFuture(Future<R> resultFuture,
Future... futures) |
static Future |
applyErrorHandling(Future future,
org.openbase.jul.iface.Processable<Exception,Void> errorProcessor,
long timeout,
TimeUnit timeUnit)
This method applies an error handler to the given future object.
|
static Future |
applyErrorHandling(Future future,
org.openbase.jul.iface.Processable<Exception,Void> errorProcessor,
long timeout,
TimeUnit timeUnit,
ExecutorService executorService)
This method applies an error handler to the given future object.
|
static <R> Future<R> |
atLeastOne(Callable<R> resultCallable,
Collection<Future> futureCollection,
long timeout,
TimeUnit timeUnit) |
static <R> Future<R> |
atLeastOne(ExecutorService executorService,
Callable<R> resultCallable,
Collection<Future> futureCollection,
long timeout,
TimeUnit timeUnit)
Method generates a new futures which represents all futures provided by the futureCollection.
|
static <R> Future<R> |
atLeastOne(R returnValue,
Collection<Future> futureCollection,
long timeout,
TimeUnit timeUnit) |
static <I,O> Collection<Future<O>> |
buildFutureCollection(Collection<I> inputList,
org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor)
Method builds a future collection with the given task processor.
|
void |
forceShutdown() |
int |
getExecutorLoad() |
ES |
getExecutorService() |
void |
internalExecute(Runnable runnable) |
<T> Future<T> |
internalSubmit(Callable<T> task) |
Future<?> |
internalSubmit(Runnable task) |
void |
shutdown() |
void |
shutdown(long shutdownTimeout,
TimeUnit timeUnit) |
void |
smartShutdown() |
String |
toString()
Simply prints the class name.
|
public static final long DEFAULT_SHUTDOWN_DELAY
public static final long DEFAULT_SHUTDOWN_TIME
public static final long SMART_SHUTDOWN_TIMEOUT
public static final long SMART_SHUTDOWN_STATUS_PRINT_RATE
public static final long DEFAULT_REPORT_RATE
public static final double DEFAULT_WARNING_RATIO
protected final ES extends ThreadPoolExecutor executorService
protected final org.slf4j.Logger logger
public AbstractExecutorService(ES executorService) throws CouldNotPerformException
CouldNotPerformExceptionpublic int getExecutorLoad()
public void internalExecute(Runnable runnable)
public ES getExecutorService()
public void shutdown()
shutdown in interface org.openbase.jul.iface.Shutdownablepublic void smartShutdown()
public void shutdown(long shutdownTimeout,
TimeUnit timeUnit)
public void forceShutdown()
public static Future applyErrorHandling(Future future, org.openbase.jul.iface.Processable<Exception,Void> errorProcessor, long timeout, TimeUnit timeUnit, ExecutorService executorService) throws CouldNotPerformException
future - the future on which is the error processor is registered.timeout - the timeout.errorProcessor - the processable which handles thrown exceptionstimeUnit - the unit of the timeout.executorService - the execution service to apply the handler.CouldNotPerformException - thrown by the errorProcessorpublic static Future applyErrorHandling(Future future, org.openbase.jul.iface.Processable<Exception,Void> errorProcessor, long timeout, TimeUnit timeUnit) throws CouldNotPerformException
future - the future on which is the error processor is registered.timeout - the timeout.errorProcessor - the processable which handles thrown exceptionstimeUnit - the unit of the timeout.CouldNotPerformException - thrown by the errorProcessorpublic static <I,R> Future<R> allOf(ExecutorService executorService, Collection<I> inputList, org.openbase.jul.iface.Processable<I,Future<Void>> taskProcessor)
public static <I,R> Future<R> allOf(Collection<I> inputList, org.openbase.jul.iface.Processable<I,Future<R>> taskProcessor) throws CouldNotPerformException
CouldNotPerformExceptionpublic static <I,O,R> Future<R> allOf(Collection<I> inputList, org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor, org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor) throws CouldNotPerformException, InterruptedException
public static <R> Future<R> allOfInclusiveResultFuture(Future<R> resultFuture, Future... futures)
public static <R> Future<R> allOf(Collection<Future> futureCollection)
public static <R> Future<R> allOf(R returnValue, Collection<Future> futureCollection)
public static <R> Future<R> allOf(ExecutorService executorService, R returnValue, Collection<Future> futureCollection)
public static <I,O,R> Future<R> allOf(ExecutorService executorService, Collection<I> inputList, org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor, org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor)
public static <R> Future<R> allOf(Callable<R> resultCallable, Collection<Future> futureCollection)
R - The result type of the outer future.resultCallable - the callable which provides the result of the outer future.futureCollection - the inner future collection.public static <R> Future<R> allOf(ExecutorService executorService, Callable<R> resultCallable, Collection<Future> futureCollection)
R - The result type of the outer future.executorService - the execution service which is used for the outer future execution.resultCallable - the callable which provides the result of the outer future.futureCollection - the inner future collection.public static <R> Future<R> atLeastOne(R returnValue, Collection<Future> futureCollection, long timeout, TimeUnit timeUnit)
public static <R> Future<R> atLeastOne(Callable<R> resultCallable, Collection<Future> futureCollection, long timeout, TimeUnit timeUnit)
public static <R> Future<R> atLeastOne(ExecutorService executorService, Callable<R> resultCallable, Collection<Future> futureCollection, long timeout, TimeUnit timeUnit)
R - The result type of the outer future.executorService - the execution service which is used for the outer future execution.resultCallable - the callable which provides the result of the outer future.futureCollection - the inner future collecttimeout - timeUnit - public static <O,R> Future<R> allOf(org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor, Collection<Future<O>> futureCollection)
O - The output or result type of the futures provided by the future collection.R - The result type of the outer future.resultProcessor - the processor which provides the outer future result.futureCollection - the inner future collection.public static <O,R> Future<R> allOf(ExecutorService executorService, org.openbase.jul.iface.Processable<Collection<Future<O>>,R> resultProcessor, Collection<Future<O>> futureCollection)
O - The output or result type of the futures provided by the future collection.R - The result type of the outer future.executorService - the execution service which is used for the outer future execution.resultProcessor - the processor which provides the outer future result.futureCollection - the inner future collection.public static <I,O> Collection<Future<O>> buildFutureCollection(Collection<I> inputList, org.openbase.jul.iface.Processable<I,Future<O>> taskProcessor) throws CouldNotPerformException, InterruptedException
I - The type of the input value used for the future build.O - The type of the output value which the futures provide.inputList - the input list which is needed for the build process.taskProcessor - the task processor to build the futures.CouldNotPerformException - is thrown if the future collection could not be generated.InterruptedException - is thrown if the thread was externally interrupted.Copyright © 2015–2017 openbase.org. All rights reserved.