Interface SequentialExecutor
-
- All Superinterfaces:
Terminable
- All Known Implementing Classes:
ConseqExecutor
public interface SequentialExecutor extends Terminable
Main API of conseq executor, bypassing the intermediate (ExecutorService) API, to service the submitted task per its sequence key.A public implementation should be thread-safe. In the context of asynchronous concurrency and sequencing, thread-safety goes beyond the concerns of data corruption due to concurrent modification, into that of execution order across multiple tasks. By definition, though, there is no such thing as order or sequence among tasks submitted concurrently by different threads. Such multi-thread submitted tasks can be executed in any order, regardless of sequence key. However, tasks submitted by a single thread - or, by each single thread in a multi-threading scenario - should be executed sequentially in the same order of submission if they have the same sequence key; otherwise, such single-thread submitted tasks should be managed to execute concurrently by multiple threads if they have different sequence keys.
- Author:
- Qingtian Wang
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Future<Void>execute(Runnable command, Object sequenceKey)<T> Future<T>submit(Callable<T> task, Object sequenceKey)-
Methods inherited from interface conseq4j.Terminable
isTerminated, shutdown
-
-
-
-
Method Detail
-
execute
Future<Void> execute(Runnable command, Object sequenceKey)
- Parameters:
command- the Runnable task to run sequentially with others under the same sequence keysequenceKey- the key under which all tasks are executed sequentially- Returns:
- future holding run status of the submitted command
-
submit
<T> Future<T> submit(Callable<T> task, Object sequenceKey)
- Type Parameters:
T- the type of the task's result- Parameters:
task- the Callable task to run sequentially with others under the same sequence keysequenceKey- the key under which all tasks are executed sequentially- Returns:
- a Future representing pending completion of the submitted task
-
-