public interface EventExecutor
Handle the all events submitted and schedule to the executor.
All Runnable and Callable submitted to an executor are guaranteed to be executed by the same thread. This means that the events don't need to handle concurrent access to shared state.
When canceling the futures returned by the submit and schedule methods the Runnable and Callable will not be executed. This is a best effort. If the task is already running then the Runnable and Callable will execute but the future may not get updated.
Shutting down the event executor will make it so that it will stop accepting new tasks for execution. The methods submit and schedule will throw a RejectedExecutionException when called after calling shutdown. All scheduled tasks that have not expired will not be executed by the event executor.
Modifier and Type | Method and Description |
---|---|
<T> CompletableFuture<T> |
schedule(Callable<T> task,
long delay,
TimeUnit unit)
Submits a task for delayed execution.
|
CompletableFuture<Void> |
schedule(Runnable task,
long delay,
TimeUnit unit)
Submits a task for delayed execution.
|
CompletableFuture<Void> |
shutdown()
Shuts down the event executor.
|
<T> CompletableFuture<T> |
submit(Callable<T> task)
Submits a task for immediate execution.
|
CompletableFuture<Void> |
submit(Runnable task)
Submits a task for immediate execution.
|
CompletableFuture<Void> submit(Runnable task)
task
- runnable to execute<T> CompletableFuture<T> submit(Callable<T> task)
task
- callable to executeCompletableFuture<Void> schedule(Runnable task, long delay, TimeUnit unit)
task
- runnable to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameter<T> CompletableFuture<T> schedule(Callable<T> task, long delay, TimeUnit unit)
task
- runnable to executedelay
- the time from now to delay executionunit
- the time unit of the delay parameterCompletableFuture<Void> shutdown()
No additional task will be accepted by the submit and schedule methods. Both methods will throw a RejectedExecutionException after this method is called.
All scheduled tasks that have not expired will not be executed by the event executor.