Package org.jtrim2.executor
Class AbstractTaskExecutorService
java.lang.Object
org.jtrim2.executor.AbstractTaskExecutor
org.jtrim2.executor.AbstractTaskExecutorService
- All Implemented Interfaces:
Executor,TaskExecutor,TaskExecutorService
- Direct Known Subclasses:
AbstractTerminateNotifierTaskExecutorService
public abstract class AbstractTaskExecutorService
extends AbstractTaskExecutor
implements TaskExecutorService
Defines a convenient abstract base class for
TaskExecutorService
implementations.
AbstractTaskExecutorService extends AbstractTaskExecutor with
automatically canceling the task if the executor was shut down, so implementations
does not need to check for shut down.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jtrim2.executor.AbstractTaskExecutor
AbstractTaskExecutor.SubmittedTask<V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V> CompletionStage<V>executeFunction(CancellationToken cancelToken, CancelableFunction<? extends V> function) Executes the function at some time in the future.Methods inherited from class org.jtrim2.executor.AbstractTaskExecutor
submitTaskMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jtrim2.executor.TaskExecutor
execute, execute, executeStagedMethods inherited from interface org.jtrim2.executor.TaskExecutorService
addTerminateListener, awaitTermination, isShutdown, isTerminated, shutdown, shutdownAndCancel, tryAwaitTermination
-
Constructor Details
-
AbstractTaskExecutorService
public AbstractTaskExecutorService()
-
-
Method Details
-
executeFunction
public <V> CompletionStage<V> executeFunction(CancellationToken cancelToken, CancelableFunction<? extends V> function) Executes the function at some time in the future. When and on what thread, the function is to be executed is completely implementation dependent. Implementations may choose to execute tasks later on a separate thread or synchronously in the calling thread at the discretion of the implementation.- Specified by:
executeFunctionin interfaceTaskExecutor- Overrides:
executeFunctionin classAbstractTaskExecutor- Type Parameters:
V- the type of the result of the submitted function- Parameters:
cancelToken- theCancellationTokenwhich is to be checked if the submitted task is to be canceled. If thisCancellationTokensignals a cancellation request, thisTaskExecutormay choose to not even attempt to execute the submitted task. This argument may not benull. When the task cannot be canceled, use the staticCancellation.UNCANCELABLE_TOKENfor this argument (even in this case, theTaskExecutormay be able to cancel the task, if it was not submitted for execution).function- the function to be executed by thisTaskExecutor. This argument cannot benull.- Returns:
- the
CompletionStagewhich can be used to execute tasks after the completion of the submitted function and process the result of the submitted function. This method never returnsnull. - See Also:
-