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 unit s time has passed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
submit, submit, submitCallable, submitRunnable, timer, timer
closeAsyncGracefully
public 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
Executor
task
as soon as possible.execute
in interface Executor
task
- 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
Executor
task
after delay
amount of unit
s 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 Executor
task
- 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()
ListenableAsyncCloseable
Completable
that is notified once the ListenableAsyncCloseable
was closed.onClose
in interface ListenableAsyncCloseable
Completable
that is notified on close.public Completable closeAsync()
AsyncCloseable
closeAsync
in interface AsyncCloseable
CompletableSource
that is notified once the close is complete.public SignalOffloader newSignalOffloader(Executor executor)
SignalOffloaderFactory
SignalOffloader
.newSignalOffloader
in interface SignalOffloaderFactory
executor
- Executor
to be used by the returned SignalOffloader
.SignalOffloader
.public boolean hasThreadAffinity()
SignalOffloaderFactory
true
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 SignalOffloaderFactory
true
if and only if all SignalOffloader
instances will always provide thread affinity.