类 TaskExecutorAdapter
- 所有已实现的接口:
AsyncListenableTaskExecutor,AsyncTaskExecutor,TaskExecutor,Executor
java.util.concurrent.Executor and
exposes a TaskExecutor for it.
Also detects an extended java.util.concurrent.ExecutorService, adapting
the AsyncTaskExecutor interface accordingly.- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
字段从接口继承的字段 cn.taketoday.core.task.AsyncTaskExecutor
TIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE -
构造器概要
构造器构造器说明TaskExecutorAdapter(Executor concurrentExecutor) Create a new TaskExecutorAdapter, using the given JDK concurrent executor. -
方法概要
修饰符和类型方法说明protected voiddoExecute(Executor concurrentExecutor, TaskDecorator taskDecorator, Runnable runnable) Actually execute the givenRunnable(which may be a user-supplied task or a wrapper around a user-supplied task) with the given executor.voidDelegates to the specified JDK concurrent executor.final voidsetTaskDecorator(TaskDecorator taskDecorator) Specify a customTaskDecoratorto be applied to anyRunnableabout to be executed.Future<?>Submit a Runnable task for execution, receiving a Future representing that task.<T> Future<T>Submit a Callable task for execution, receiving a Future representing that task.submitListenable(Runnable task) Submit aRunnabletask for execution, receiving aListenableFuturerepresenting that task.<T> ListenableFuture<T>submitListenable(Callable<T> task) Submit aCallabletask for execution, receiving aListenableFuturerepresenting that task.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.task.AsyncTaskExecutor
execute, submitCompletable, submitCompletable
-
字段详细资料
-
concurrentExecutor
-
taskDecorator
-
-
构造器详细资料
-
TaskExecutorAdapter
Create a new TaskExecutorAdapter, using the given JDK concurrent executor.- 参数:
concurrentExecutor- the JDK concurrent executor to delegate to
-
-
方法详细资料
-
setTaskDecorator
Specify a customTaskDecoratorto be applied to anyRunnableabout to be executed.Note that such a decorator is not necessarily being applied to the user-supplied
Runnable/Callablebut rather to the actual execution callback (which may be a wrapper around the user-supplied task).The primary use case is to set some execution context around the task's invocation, or to provide some monitoring/statistics for task execution.
NOTE: Exception handling in
TaskDecoratorimplementations is limited to plainRunnableexecution viaexecutecalls. In case of#submitcalls, the exposedRunnablewill be aFutureTaskwhich does not propagate any exceptions; you might have to cast it and callFuture#getto evaluate exceptions. -
execute
Delegates to the specified JDK concurrent executor.- 指定者:
execute在接口中Executor- 指定者:
execute在接口中TaskExecutor- 参数:
task- theRunnableto execute (nevernull)- 另请参阅:
-
submit
从接口复制的说明:AsyncTaskExecutorSubmit a Runnable task for execution, receiving a Future representing that task. The Future will return anullresult upon completion.this method comes with a default implementation that delegates to
TaskExecutor.execute(Runnable).- 指定者:
submit在接口中AsyncTaskExecutor- 参数:
task- theRunnableto execute (nevernull)- 返回:
- a Future representing pending completion of the task
-
submit
从接口复制的说明:AsyncTaskExecutorSubmit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.this method comes with a default implementation that delegates to
TaskExecutor.execute(Runnable).- 指定者:
submit在接口中AsyncTaskExecutor- 参数:
task- theCallableto execute (nevernull)- 返回:
- a Future representing pending completion of the task
-
submitListenable
从接口复制的说明:AsyncListenableTaskExecutorSubmit aRunnabletask for execution, receiving aListenableFuturerepresenting that task. The Future will return anullresult upon completion.in favor of
AsyncTaskExecutor.submitCompletable(Runnable)- 指定者:
submitListenable在接口中AsyncListenableTaskExecutor- 参数:
task- theRunnableto execute (nevernull)- 返回:
- a
ListenableFuturerepresenting pending completion of the task
-
submitListenable
从接口复制的说明:AsyncListenableTaskExecutorSubmit aCallabletask for execution, receiving aListenableFuturerepresenting that task. The Future will return the Callable's result upon completion.in favor of
AsyncTaskExecutor.submitCompletable(Callable)- 指定者:
submitListenable在接口中AsyncListenableTaskExecutor- 参数:
task- theCallableto execute (nevernull)- 返回:
- a
ListenableFuturerepresenting pending completion of the task
-
doExecute
protected void doExecute(Executor concurrentExecutor, @Nullable TaskDecorator taskDecorator, Runnable runnable) throws RejectedExecutionException Actually execute the givenRunnable(which may be a user-supplied task or a wrapper around a user-supplied task) with the given executor.- 参数:
concurrentExecutor- the underlying JDK concurrent executor to delegate totaskDecorator- the specified decorator to be applied, if anyrunnable- the runnable to execute- 抛出:
RejectedExecutionException- if the given runnable cannot be accepted
-