Package io.servicetalk.concurrent.api
Class DelegatingExecutor
java.lang.Object
io.servicetalk.concurrent.api.DelegatingAsyncCloseable<T>
io.servicetalk.concurrent.api.DelegatingListenableAsyncCloseable<Executor>
io.servicetalk.concurrent.api.DelegatingExecutor
- All Implemented Interfaces:
AsyncCloseable,Executor,ListenableAsyncCloseable,Executor,TimeSource
public class DelegatingExecutor
extends DelegatingListenableAsyncCloseable<Executor>
implements Executor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcurrentTime(TimeUnit unit) Returns the internal clock time in the specifiedunit.protected Executordelegate()Get theExecutorthat this class delegates to.Executes the passedtaskas soon as possible.Executes the passedtaskafterdelayamount ofunits time has passed.Executes the passedtaskafterdelayamount time has passed.Create a newCompletablethat executes the passedRunnableon each subscribe.<T> Single<T><T> Single<T>submitCallable(Supplier<? extends Callable<? extends T>> callableSupplier) submitRunnable(Supplier<Runnable> runnableSupplier) Creates a newCompletablethat creates and executes aRunnablewhen subscribed to.Creates a newCompletablethat will complete after the time duration expires.Creates a newCompletablethat will complete after the time duration expires.Methods inherited from class io.servicetalk.concurrent.api.DelegatingListenableAsyncCloseable
onClose, onClosingMethods inherited from class io.servicetalk.concurrent.api.DelegatingAsyncCloseable
closeAsync, closeAsyncGracefully, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefullyMethods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose, onClosing
-
Constructor Details
-
DelegatingExecutor
New instance.- Parameters:
delegate-Executorto delegate all calls to.
-
-
Method Details
-
delegate
Get theExecutorthat this class delegates to.- Overrides:
delegatein classDelegatingListenableAsyncCloseable<Executor>- Returns:
- the
Executorthat this class delegates to.
-
execute
Description copied from interface:ExecutorExecutes the passedtaskas soon as possible.- Specified by:
executein interfaceExecutor- Parameters:
task- to execute.- Returns:
Cancellableto cancel the task if not yet executed.- Throws:
RejectedExecutionException- If the task is rejected.
-
schedule
public Cancellable schedule(Runnable task, long delay, TimeUnit unit) throws RejectedExecutionException Description copied from interface:ExecutorExecutes 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.
- Specified by:
schedulein interfaceExecutor- 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
Description copied from interface:ExecutorExecutes 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.
- Specified by:
schedulein interfaceExecutor- 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.
-
timer
Description copied from interface:ExecutorCreates a newCompletablethat will complete after the time duration expires.- Specified by:
timerin interfaceExecutor- Parameters:
delay- The time duration which is allowed to elapse between subscribe and termination.unit- The units forduration.- Returns:
- a new
Completablethat will complete after the time duration expires. - See Also:
-
timer
Description copied from interface:ExecutorCreates a newCompletablethat will complete after the time duration expires.- Specified by:
timerin interfaceExecutor- Parameters:
delay- The time duration which is allowed to elapse between subscribe and termination.- Returns:
- a new
Completablethat will complete after the time duration expires. - See Also:
-
submit
Description copied from interface:ExecutorCreate a newCompletablethat executes the passedRunnableon each subscribe.- Specified by:
submitin interfaceExecutor- Parameters:
runnable- TheRunnableto execute on each subscribe.- Returns:
- a new
Completablethat executes aRunnableon each subscribe.
-
submitRunnable
Description copied from interface:ExecutorCreates a newCompletablethat creates and executes aRunnablewhen subscribed to.- Specified by:
submitRunnablein interfaceExecutor- Parameters:
runnableSupplier-Supplierto create a newRunnablefor every subscribe of the returnedCompletable.- Returns:
- A new
Completablethat creates and executes a newRunnableusingrunnableSupplierfor every subscribe.
-
submit
Description copied from interface:Executor -
submitCallable
Description copied from interface:Executor- Specified by:
submitCallablein interfaceExecutor- Type Parameters:
T- Type of theSingle.- Parameters:
callableSupplier-Supplierto create a newCallablefor every call to subscribe to the returnedSingle.- Returns:
- A new
Singlethat creates and executes a newCallableusingcallableSupplierfor every subscribe.
-
currentTime
Description copied from interface:TimeSourceReturns the internal clock time in the specifiedunit.- Specified by:
currentTimein interfaceExecutor- Specified by:
currentTimein interfaceTimeSource- Parameters:
unit- the time unit to calculate- Returns:
- the internal clock time in the specified
unit.
-