Package io.servicetalk.concurrent
Interface Executor
-
- All Known Subinterfaces:
Executor
- All Known Implementing Classes:
DelegatingExecutor,OffloaderAwareExecutor,TestExecutor
public interface ExecutorA general abstraction to execute immediate and delayed tasks.Long running tasks
Executorimplementations are expected to run long running (blocking) tasks which may depend on other tasks submitted to the sameExecutorinstance. In order to avoid deadlocks, it is generally a good idea to not allow task queuing in theExecutor.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Cancellableexecute(java.lang.Runnable task)Executes the passedtaskas soon as possible.Cancellableschedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)Executes the passedtaskafterdelayamount ofunits time has passed.default Cancellableschedule(java.lang.Runnable task, java.time.Duration delay)Executes the passedtaskafterdelayamount time has passed.
-
-
-
Method Detail
-
execute
Cancellable execute(java.lang.Runnable task) throws java.util.concurrent.RejectedExecutionException
Executes the passedtaskas soon as possible.- Parameters:
task- to execute.- Returns:
Cancellableto cancel the task if not yet executed.- Throws:
java.util.concurrent.RejectedExecutionException- If the task is rejected.
-
schedule
Cancellable schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.RejectedExecutionException
Executes the passedtaskafterdelayamount ofunits time has passed.Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.
- Parameters:
task- to execute.delay- The time duration that is allowed to elapse beforetaskis executed.unit- The units fordelay.- Returns:
Cancellableto cancel the task if not yet executed.- Throws:
java.util.concurrent.RejectedExecutionException- If the task is rejected.
-
schedule
default Cancellable schedule(java.lang.Runnable task, java.time.Duration delay) throws java.util.concurrent.RejectedExecutionException
Executes the passedtaskafterdelayamount time has passed.Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.
- Parameters:
task- to execute.delay- The time duration that is allowed to elapse beforetaskis executed.- Returns:
Cancellableto cancel the task if not yet executed.- Throws:
java.util.concurrent.RejectedExecutionException- If the task is rejected.
-
-