public final class OffloaderAwareExecutor extends java.lang.Object implements Executor, SignalOffloaderFactory
Executor which is also a SignalOffloaderFactory and hence can influence a specific
SignalOffloader used by this Executor.| Constructor and Description |
|---|
OffloaderAwareExecutor(Executor delegate,
SignalOffloaderFactory offloaderFactory)
New instance.
|
| Modifier and Type | Method and Description |
|---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
static Executor |
ensureThreadAffinity(Executor executor)
|
Cancellable |
execute(java.lang.Runnable task)
Executes the passed
task as soon as possible. |
boolean |
hasThreadAffinity()
Returns
true if and only if all SignalOffloader instances will always provide thread affinity. |
SignalOffloader |
newSignalOffloader(Executor executor)
Creates a new
SignalOffloader. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
Cancellable |
schedule(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit unit)
Executes the passed
task after delay amount of units time has passed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsubmit, submit, submitCallable, submitRunnable, timer, timercloseAsyncGracefullypublic OffloaderAwareExecutor(Executor delegate, SignalOffloaderFactory offloaderFactory)
delegate - Actual Executor to use.offloaderFactory - SignalOffloaderFactory to use.public Cancellable execute(java.lang.Runnable task) throws java.util.concurrent.RejectedExecutionException
Executortask as soon as possible.execute in interface Executortask - to execute.Cancellable to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException - If the task is rejected.public Cancellable schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.RejectedExecutionException
Executortask after delay amount of units 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.
schedule in interface Executortask - to execute.delay - The time duration that is allowed to elapse before task is executed.unit - The units for delay.Cancellable to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException - If the task is rejected.public Completable onClose()
ListenableAsyncCloseableCompletable that is notified once the ListenableAsyncCloseable was closed.onClose in interface ListenableAsyncCloseableCompletable that is notified on close.public Completable closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseableCompletableSource that is notified once the close is complete.public SignalOffloader newSignalOffloader(Executor executor)
SignalOffloaderFactorySignalOffloader.newSignalOffloader in interface SignalOffloaderFactoryexecutor - Executor to be used by the returned SignalOffloader.SignalOffloader.public boolean hasThreadAffinity()
SignalOffloaderFactorytrue if and only if all SignalOffloader instances will always provide thread affinity.
A SignalOffloader providing thread affinity will offload all signals using a single thread.hasThreadAffinity in interface SignalOffloaderFactorytrue if and only if all SignalOffloader instances will always provide thread affinity.