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 units 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
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 Cancellable schedule(java.lang.Runnable task, java.time.Duration delay) throws java.util.concurrent.RejectedExecutionException
Executortask 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 Executortask - 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)
ExecutorCompletable 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)
ExecutorCompletable 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)
ExecutorCompletable 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)
ExecutorCompletable 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)
ExecutorSingle 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)
Executorpublic 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 Completable closeAsyncGracefully()
AsyncCloseableAsyncCloseable.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 AsyncCloseableCompletable that is notified once the close is complete.