public abstract class DelegatingExecutor extends java.lang.Object implements Executor
Constructor and Description |
---|
DelegatingExecutor(Executor delegate)
New instance.
|
Modifier and Type | Method and Description |
---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync() , but attempts to cleanup state before
abruptly closing. |
Cancellable |
execute(java.lang.Runnable task)
Executes the passed
task as soon as possible. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
Cancellable |
schedule(java.lang.Runnable task,
java.time.Duration delay)
Executes the passed
task after delay amount time has passed. |
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. |
<T> Single<T> |
submit(java.util.concurrent.Callable<? extends T> callable)
Creates a new
Single that creates and executes the passed Callable when subscribed to. |
Completable |
submit(java.lang.Runnable runnable)
Create a new
Completable that executes the passed Runnable on each subscribe. |
<T> Single<T> |
submitCallable(java.util.function.Supplier<? extends java.util.concurrent.Callable<? extends T>> callableSupplier)
|
Completable |
submitRunnable(java.util.function.Supplier<java.lang.Runnable> runnableSupplier)
Creates a new
Completable that creates and executes a Runnable when subscribed to. |
Completable |
timer(java.time.Duration delay)
Creates a new
Completable that will complete after the time duration expires. |
Completable |
timer(long delay,
java.util.concurrent.TimeUnit unit)
Creates a new
Completable that will complete after the time duration expires. |
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 Cancellable schedule(java.lang.Runnable task, java.time.Duration delay) throws java.util.concurrent.RejectedExecutionException
Executor
task
after delay
amount 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.Cancellable
to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException
- If the task is rejected.public Completable timer(long delay, java.util.concurrent.TimeUnit unit)
Executor
Completable
that will complete after the time duration expires.delay
- The time duration which is allowed to elapse between subscribe and termination.unit
- The units for duration
.Completable
that will complete after the time duration expires.public Completable timer(java.time.Duration delay)
Executor
Completable
that will complete after the time duration expires.delay
- The time duration which is allowed to elapse between subscribe and termination.Completable
that will complete after the time duration expires.public Completable submit(java.lang.Runnable runnable)
Executor
Completable
that executes the passed Runnable
on each subscribe.runnable
- The Runnable
to execute on each subscribe.Completable
that executes a Runnable
on each subscribe.public Completable submitRunnable(java.util.function.Supplier<java.lang.Runnable> runnableSupplier)
Executor
Completable
that creates and executes a Runnable
when subscribed to.runnableSupplier
- Supplier
to create a new Runnable
for every subscribe of the returned
Completable
.Completable
that creates and executes a new Runnable
using
runnableSupplier
for every subscribe.public <T> Single<T> submit(java.util.concurrent.Callable<? extends T> callable)
Executor
Single
that creates and executes the passed Callable
when subscribed to.public <T> Single<T> submitCallable(java.util.function.Supplier<? extends java.util.concurrent.Callable<? extends T>> callableSupplier)
Executor
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 Completable closeAsyncGracefully()
AsyncCloseable
AsyncCloseable.closeAsync()
, but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync()
.
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync()
.
closeAsyncGracefully
in interface AsyncCloseable
Completable
that is notified once the close is complete.