public static interface Scheduler.Worker extends Disposable
Disposable.Composite, Disposable.Swap
Modifier and Type | Method and Description |
---|---|
Disposable |
schedule(Runnable task)
Schedules the task for immediate execution on this worker.
|
default Disposable |
schedule(Runnable task,
long delay,
TimeUnit unit)
Schedules the execution of the given task with the given delay amount.
|
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.
|
dispose, isDisposed
Disposable schedule(Runnable task)
task
- the task to scheduleDisposable
instance that lets one cancel this particular task.
If the Scheduler has been shut down, a RejectedExecutionException
is thrown.default Disposable schedule(Runnable task, long delay, TimeUnit unit)
This method is safe to be called from multiple threads and tasks are executed in some total order. Two tasks scheduled at the 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.
task
- the task to scheduledelay
- the delay amount, non-positive values indicate non-delayed schedulingunit
- the unit of measure of the delay amountDisposable
that lets one cancel this particular delayed task,
or throw a RejectedExecutionException
if the Worker is not capable of scheduling with delay.default Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit)
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.
task
- the task to scheduleinitialDelay
- the initial delay amount, non-positive values indicate non-delayed schedulingperiod
- the period at which the task should be re-executedunit
- the unit of measure of the delay amountDisposable
that lets one cancel this particular delayed task,
or throw a RejectedExecutionException
if the Worker is not capable of scheduling periodically.