Class OffloaderAwareExecutor
- java.lang.Object
-
- io.servicetalk.concurrent.api.internal.OffloaderAwareExecutor
-
- All Implemented Interfaces:
AsyncCloseable,Executor,ListenableAsyncCloseable,Executor,SignalOffloaderFactory
public final class OffloaderAwareExecutor extends java.lang.Object implements Executor, SignalOffloaderFactory
AnExecutorwhich is also aSignalOffloaderFactoryand hence can influence a specificSignalOffloaderused by thisExecutor.
-
-
Constructor Summary
Constructors Constructor Description OffloaderAwareExecutor(Executor delegate, SignalOffloaderFactory offloaderFactory)New instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletablecloseAsync()Used to close/shutdown a resource.static ExecutorensureThreadAffinity(Executor executor)Cancellableexecute(java.lang.Runnable task)Executes the passedtaskas soon as possible.booleanhasThreadAffinity()Returnstrueif and only if allSignalOffloaderinstances will always provide thread affinity.SignalOffloadernewSignalOffloader(Executor executor)Creates a newSignalOffloader.CompletableonClose()Returns aCompletablethat is notified once theListenableAsyncCloseablewas closed.Cancellableschedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)Executes the passedtaskafterdelayamount ofunits time has passed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsyncGracefully
-
Methods inherited from interface io.servicetalk.concurrent.api.Executor
submit, submit, submitCallable, submitRunnable, timer, timer
-
-
-
-
Constructor Detail
-
OffloaderAwareExecutor
public OffloaderAwareExecutor(Executor delegate, SignalOffloaderFactory offloaderFactory)
New instance.- Parameters:
delegate- ActualExecutorto use.offloaderFactory-SignalOffloaderFactoryto use.
-
-
Method Detail
-
execute
public Cancellable execute(java.lang.Runnable task) throws java.util.concurrent.RejectedExecutionException
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:
java.util.concurrent.RejectedExecutionException- If the task is rejected.
-
schedule
public Cancellable schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.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:
java.util.concurrent.RejectedExecutionException- If the task is rejected.
-
onClose
public Completable onClose()
Description copied from interface:ListenableAsyncCloseableReturns aCompletablethat is notified once theListenableAsyncCloseablewas closed.- Specified by:
onClosein interfaceListenableAsyncCloseable- Returns:
- the
Completablethat is notified on close.
-
closeAsync
public Completable closeAsync()
Description copied from interface:AsyncCloseableUsed to close/shutdown a resource.- Specified by:
closeAsyncin interfaceAsyncCloseable- Returns:
- A
Completablethat is notified once the close is complete.
-
newSignalOffloader
public SignalOffloader newSignalOffloader(Executor executor)
Description copied from interface:SignalOffloaderFactoryCreates a newSignalOffloader.- Specified by:
newSignalOffloaderin interfaceSignalOffloaderFactory- Parameters:
executor-Executorto be used by the returnedSignalOffloader.- Returns:
- A new
SignalOffloader.
-
hasThreadAffinity
public boolean hasThreadAffinity()
Description copied from interface:SignalOffloaderFactoryReturnstrueif and only if allSignalOffloaderinstances will always provide thread affinity. ASignalOffloaderproviding thread affinity will offload all signals using a single thread.- Specified by:
hasThreadAffinityin interfaceSignalOffloaderFactory- Returns:
trueif and only if allSignalOffloaderinstances will always provide thread affinity.
-
-