Implementations that use an underlying ExecutorService or
ScheduledExecutorService should decorate it with the relevant Schedulers hook
(Schedulers#decorateExecutorService(Scheduler, ScheduledExecutorService).
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Scheduler.Worker
A worker representing an asynchronous boundary that executes tasks. |
| Modifier and Type | Method and Description |
|---|---|
| public Scheduler. | |
| public default void | dispose()
Implements reactor. |
| public default Mono | disposeGracefully()
Lazy variant of |
| public default void | |
| public default long | |
| public Disposable | Returns: theDisposable instance that let's one cancel this particular task.
If the Scheduler has been shut down, throw a RejectedExecutionException.the task to execute task)Schedules the non-delayed execution of the given task on this scheduler. |
| public default Disposable | Returns: theDisposable that let's one cancel this particular delayed task,
or throw a RejectedExecutionException if the Scheduler is not capable of scheduling with delay.the task to schedule task, long the delay amount, non-positive values indicate non-delayed scheduling delay, TimeUnit the unit of measure of the delay amount unit)Schedules the execution of the given task with the given delay amount. |
| public default Disposable | Returns: theDisposable that let's one cancel this particular delayed task,
or throw a RejectedExecutionException if the Scheduler is not capable of scheduling periodically.the task to schedule task, long the initial delay amount, non-positive values indicate non-delayed scheduling initialDelay, long the period at which the task should be re-executed period, TimeUnit the unit of measure of the delay amount unit)Schedules a periodic execution of the given task with the given initial delay and period. |
| public default void |
| createWorker | back to summary |
|---|---|
| public Scheduler. Creates a worker of this Scheduler.
Once the Worker is no longer in use, one should call dispose() on it to
release any resources the particular Scheduler may have used.
It depends on the implementation, but Scheduler Workers should usually run tasks in
FIFO order. Some implementations may entirely delegate the scheduling to an
underlying structure (like an | |
| dispose | back to summary |
|---|---|
| public default void dispose() Implements reactor. Instructs this Scheduler to release all resources and reject any new tasks to be executed. The operation is thread-safe. The Scheduler may choose to ignore this instruction. When used in combination with | |
| disposeGracefully | back to summary |
|---|---|
| public default Mono Lazy variant of It is advised to apply a The returned | |
| init | back to summary |
|---|---|
| public default void init() Instructs this Scheduler to prepare itself for running tasks
directly or through its Implementations are encouraged to throw an exception if this method is called
after the scheduler has been disposed via | |
| now | back to summary |
|---|---|
| public default long now(TimeUnit unit) Returns the "current time" notion of this scheduler. Implementation Note The default implementation uses
| |
| schedule | back to summary |
|---|---|
| public Disposable schedule(Runnable task) Schedules the non-delayed execution of the given task on this scheduler. This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
| |
| schedule | back to summary |
|---|---|
| public default Disposable schedule(Runnable task, long delay, TimeUnit unit) Schedules the execution of the given task with the given delay amount. This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
| |
| schedulePeriodically | back to summary |
|---|---|
| public default Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit) Schedules a periodic execution of the given task with the given initial delay and period. This method is safe to be called from multiple threads but there are no ordering guarantees between tasks. The periodic execution is at a fixed rate, that is, the first execution will be after the initial delay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.
| |
| start | back to summary |
|---|---|
| public default void start()
Deprecated Use Instructs this Scheduler to prepare itself for running tasks directly or through its Workers. The operation is thread-safe but one should avoid using start() and dispose() concurrently as it would non-deterministically leave the Scheduler in either active or inactive state.
| |
| Modifier and Type | Method and Description |
|---|---|
| public Disposable | Returns: theDisposable instance that let's one cancel this particular task.
If the Scheduler has been shut down, a RejectedExecutionException is thrown.the task to schedule task)Schedules the task for immediate execution on this worker. |
| public default Disposable | Returns: theDisposable that let's one cancel this particular delayed task,
or throw a RejectedExecutionException if the Worker is not capable of scheduling with delay.the task to schedule task, long the delay amount, non-positive values indicate non-delayed scheduling delay, TimeUnit the unit of measure of the delay amount unit)Schedules the execution of the given task with the given delay amount. |
| public default Disposable | Returns: theDisposable that let's one cancel this particular delayed task,
or throw a RejectedExecutionException if the Worker is not capable of scheduling periodically.the task to schedule task, long the initial delay amount, non-positive values indicate non-delayed scheduling initialDelay, long the period at which the task should be re-executed period, TimeUnit the unit of measure of the delay amount unit)Schedules a periodic execution of the given task with the given initial delay and period. |
| schedule | back to summary |
|---|---|
| public Disposable schedule(Runnable task) Schedules the task for immediate execution on this worker.
| |
| schedule | back to summary |
|---|---|
| public default Disposable schedule(Runnable task, long delay, TimeUnit unit) Schedules the execution of the given task with the given delay amount. This method is safe to be called from multiple threads and tasks are executed in some total order. Two tasks scheduled at a same time with the same delay will be ordered in FIFO order if the schedule() was called from the same thread or in arbitrary order if the schedule() was called from different threads.
| |
| schedulePeriodically | back to summary |
|---|---|
| public default Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit) Schedules a periodic execution of the given task with the given initial delay and period. This method is safe to be called from multiple threads. The periodic execution is at a fixed rate, that is, the first execution will be after the initial delay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.
| |