Package io.servicetalk.concurrent
Interface Executor
- All Superinterfaces:
TimeSource
- All Known Subinterfaces:
EventLoopAwareNettyIoExecutor,Executor,IoExecutor,NettyIoExecutor
- All Known Implementing Classes:
DelegatingExecutor
A general abstraction to execute immediate and delayed tasks.
Long running tasks
Executor implementations are expected to run long running (blocking) tasks which may depend on other tasks
submitted to the same Executor instance.
In order to avoid deadlocks, it is generally a good idea to not allow task queuing in the Executor.-
Method Summary
Modifier and TypeMethodDescriptiondefault longcurrentTime(TimeUnit unit) Returns the internal clock time in the specifiedunit.Executes the passedtaskas soon as possible.Executes the passedtaskafterdelayamount ofunits time has passed.default CancellableExecutes the passedtaskafterdelayamount time has passed.
-
Method Details
-
currentTime
Description copied from interface:TimeSourceReturns the internal clock time in the specifiedunit.- Specified by:
currentTimein interfaceTimeSource- Parameters:
unit- the time unit to calculate- Returns:
- the internal clock time in the specified
unit.
-
execute
Executes the passedtaskas soon as possible.- Parameters:
task- to execute.- Returns:
Cancellableto cancel the task if not yet executed.- Throws:
RejectedExecutionException- If the task is rejected.
-
schedule
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:
RejectedExecutionException- If the task is rejected.
-
schedule
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:
RejectedExecutionException- If the task is rejected.
-