public interface ApplicationExecutors
Modifier and Type | Method and Description |
---|---|
ExecutorService |
defaultExecutor()
Default Application Executor.
|
default void |
execute(Runnable task)
Executes the given command at some time in the future in the default Application Executor.
|
default void |
execute(String executorName, Runnable task)
Executes the given command at some time in the future in a configured Application Executor.
|
ExecutorService |
executor(String executorName)
Application Executor by name.
|
boolean |
inDefaultExecutor()
Check if current thread is in the default Application Executor.
|
boolean |
inExecutor(String executorName)
Check if current thread is in a configured Application Executor.
|
default <T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks)
Executes the given tasks in the default Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
|
default <T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks in the default Application Executor, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.
|
default <T> List<Future<T>> |
invokeAll(String executorName, Collection<? extends Callable<T>> tasks)
Executes the given tasks in a configured Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
|
default <T> List<Future<T>> |
invokeAll(String executorName, Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks in a configured Application Executor, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.
|
default <T> T |
invokeAny(Collection<? extends Callable<T>> tasks)
Executes the given tasks on the default Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
|
default <T> T |
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks on the default Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses.
|
default <T> T |
invokeAny(String executorName, Collection<? extends Callable<T>> tasks)
Executes the given tasks on the default Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
|
default <T> T |
invokeAny(String executorName, Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks on a configured Application Executor, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses.
|
default CompletableFuture<Void> |
runAsync(Runnable runnable)
Returns a new CompletableFuture that is asynchronously completed by a task running in the default Application Executor after it runs the given action.
|
default CompletableFuture<Void> |
runAsync(String executorName, Runnable runnable)
Returns a new CompletableFuture that is asynchronously completed by a task running in a configured Application Executor after it runs the given action.
|
default <T> Future<T> |
submit(Callable<T> task)
Submits a value-returning task to the default Application Executor and returns a Future representing the pending results of the task.
|
default Future<?> |
submit(Runnable task)
Submits a Runnable task to the default Application Executor and returns a Future representing that task.
|
default <T> Future<T> |
submit(Runnable task, T result)
Submits a Runnable task to the default Application Executor and returns a Future representing that task.
|
default <T> Future<T> |
submit(String executorName, Callable<T> task)
Submits a value-returning task to a configured Application Executor and returns a Future representing the pending results of the task.
|
default Future<?> |
submit(String executorName, Runnable task)
Submits a Runnable task to a configured Application Executor and returns a Future representing that task.
|
default <T> Future<T> |
submit(String executorName, Runnable task, T result)
Submits a Runnable task to a configured Application Executor and returns a Future representing that task.
|
default <U> CompletableFuture<U> |
supplyAsync(String executorName, Supplier<U> supplier)
Returns a new CompletableFuture that is asynchronously completed by a task running in a configured Application Executor with the value obtained by calling the given Supplier.
|
default <U> CompletableFuture<U> |
supplyAsync(Supplier<U> supplier)
Returns a new CompletableFuture that is asynchronously completed by a task running in the default Application Executor with the value obtained by calling the given Supplier.
|
ExecutorService defaultExecutor()
boolean inDefaultExecutor()
ExecutorService executor(String executorName)
executorName
- The name of a configured Application Executor
boolean inExecutor(String executorName)
executorName
- The name of a configured Application Executor
default void execute(Runnable task)
task
- The runnable task
default void execute(String executorName, Runnable task)
executorName
- The name of a configured Application Executor
task
- The runnable task
default <T> Future<T> submit(Callable<T> task)
T
- the type of the task's result
task
- the task to submit
default <T> Future<T> submit(String executorName, Callable<T> task)
T
- The type of the task's result
executorName
- The name of a configured Application Executor
task
- The task to submit
default Future<?> submit(Runnable task)
The Future's get method will return null upon successful completion See ExecutorService.submit(java.lang.Runnable)
.
task
- The task to submit
default Future<?> submit(String executorName, Runnable task)
The Future's get method will return null upon successful completion See ExecutorService.submit(java.lang.Runnable)
.
executorName
- The name of a configured Application Executor
task
- The task to submit
default <T> Future<T> submit(Runnable task, T result)
The Future's get method will return the given result upon successful completion. See ExecutorService.submit(java.lang.Runnable)
.
T
- The type of the result
task
- The task to submit
result
- The result to return
default <T> Future<T> submit(String executorName, Runnable task, T result)
The Future's get method will return the given result upon successful completion. See ExecutorService.submit(java.lang.Runnable)
.
T
- The type of the result
executorName
- The name of a configured Application Executor
task
- The task to submit
result
- The result to return
default <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
T
- The type of the values returned from the tasks
tasks
- The collection of tasks
InterruptedException
- if interrupted while waiting
ExecutionException
- if no task successfully completes
default <T> T invokeAny(String executorName, Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
T
- The type of the values returned from the tasks
executorName
- The name of a configured Application Executor
tasks
- The collection of tasks
InterruptedException
- if interrupted while waiting
ExecutionException
- if no task successfully completes
default <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
See ExecutorService.invokeAny(java.util.Collection, long, java.util.concurrent.TimeUnit)
.
T
- The type of the values returned from the tasks
tasks
- The collection of tasks
timeout
- The maximum time to wait
unit
- The time unit of the timeout argument
InterruptedException
- if interrupted while waiting
ExecutionException
- if no task successfully completes
TimeoutException
- if the given timeout elapses before any task successfully completes
default <T> T invokeAny(String executorName, Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
See ExecutorService.invokeAny(java.util.Collection, long, java.util.concurrent.TimeUnit)
.
T
- The type of the values returned from the tasks
executorName
- The name of a configured Application Executor
tasks
- The collection of tasks
timeout
- The maximum time to wait
unit
- The time unit of the timeout argument
InterruptedException
- if interrupted while waiting
ExecutionException
- if no task successfully completes
TimeoutException
- if the given timeout elapses before any task successfully completes
default <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
T
- The type of the values returned from the tasks
tasks
- The collection of tasks
InterruptedException
- if interrupted while waiting, in which case unfinished tasks are cancelled
default <T> List<Future<T>> invokeAll(String executorName, Collection<? extends Callable<T>> tasks) throws InterruptedException
T
- The type of the values returned from the tasks
executorName
- The name of a configured Application Executor
tasks
- The collection of tasks
InterruptedException
- if interrupted while waiting, in which case unfinished tasks are cancelled
default <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
See ExecutorService.invokeAll(java.util.Collection, long, java.util.concurrent.TimeUnit)
.
T
- The type of the values returned from the tasks
tasks
- The collection of tasks
timeout
- The maximum time to wait
unit
- The time unit of the timeout argument
InterruptedException
- if interrupted while waiting, in which case unfinished tasks are cancelled
default <T> List<Future<T>> invokeAll(String executorName, Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
See ExecutorService.invokeAll(java.util.Collection, long, java.util.concurrent.TimeUnit)
.
T
- The type of the values returned from the tasks
executorName
- The name of a configured Application Executor
tasks
- The collection of tasks
timeout
- The maximum time to wait
unit
- The time unit of the timeout argument
InterruptedException
- if interrupted while waiting, in which case unfinished tasks are cancelled
default CompletableFuture<Void> runAsync(Runnable runnable)
runnable
- The action to run before completing the returned CompletableFuture
default CompletableFuture<Void> runAsync(String executorName, Runnable runnable)
executorName
- The name of a configured Application Executor
runnable
- The action to run before completing the returned CompletableFuture
default <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier)
U
- The function's return type
supplier
- a function returning the value to be used to complete the returned CompletableFuture
default <U> CompletableFuture<U> supplyAsync(String executorName, Supplier<U> supplier)
U
- The function's return type
executorName
- The name of a configured Application Executor
supplier
- a function returning the value to be used to complete the returned CompletableFuture