public static interface Scheduler.Worker extends Disposable
Modifier and Type | Method and Description |
---|---|
default void |
dispose()
Instructs this worker to cancel all pending tasks, all running tasks in
a best-effort manner, reject new tasks and
release any resources associated with it.
|
Cancellation |
schedule(Runnable task)
Schedules the task on this worker.
|
default Cancellation |
schedule(Runnable task,
long delay,
TimeUnit unit)
Schedules the execution of the given task with the given delay amount.
|
default Cancellation |
schedulePeriodically(Runnable task,
long initialDelay,
long period,
TimeUnit unit)
Schedules a periodic execution of the given task with the given initial delay and period.
|
void |
shutdown()
Deprecated.
move the implementation to
dispose() and call dispose from shutdown.
Will be removed in 3.1.0 |
isDisposed
Cancellation schedule(Runnable task)
task
- the task to scheduleCancellation
instance that let's one cancel this particular task.
If the Scheduler has been shut down, the Scheduler.REJECTED
Cancellation
instance is returned.default Cancellation 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 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.
task
- the task to scheduledelay
- the delay amount, non-positive values indicate non-delayed schedulingunit
- the unit of measure of the delay amountCancellation
that let's one cancel this particular delayed task,
or Scheduler.REJECTED
if the Worker is not capable of scheduling with delay.default Cancellation 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 amountCancellation
that let's one cancel this particular delayed task,
or Scheduler.REJECTED
if the Worker is not capable of scheduling periodically.@Deprecated void shutdown()
dispose()
and call dispose from shutdown.
Will be removed in 3.1.0default void dispose()
dispose
in interface Cancellation
dispose
in interface Disposable