public abstract static class Scheduler.Worker extends java.lang.Object implements Disposable
Disposing the Scheduler.Worker
cancels all outstanding work and allows resource cleanup.
Constructor and Description |
---|
Scheduler.Worker() |
Modifier and Type | Method and Description |
---|---|
long |
now(java.util.concurrent.TimeUnit unit)
Returns the 'current time' of the Worker in the specified time unit.
|
Disposable |
schedule(java.lang.Runnable run)
Schedules a Runnable for execution without delay.
|
abstract Disposable |
schedule(java.lang.Runnable run,
long delay,
java.util.concurrent.TimeUnit unit)
Schedules an Runnable for execution at some point in the future.
|
Disposable |
schedulePeriodically(java.lang.Runnable run,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Schedules a cancelable action to be executed periodically.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dispose, isDisposed
@NonNull public Disposable schedule(@NonNull java.lang.Runnable run)
The default implementation delegates to schedule(Runnable, long, TimeUnit)
.
run
- Runnable to schedule@NonNull public abstract Disposable schedule(@NonNull java.lang.Runnable run, long delay, @NonNull java.util.concurrent.TimeUnit unit)
Note to implementors: non-positive delayTime
should be regarded as non-delayed schedule, i.e.,
as if the schedule(Runnable)
was called.
run
- the Runnable to scheduledelay
- time to wait before executing the action; non-positive values indicate an non-delayed
scheduleunit
- the time unit of delayTime
@NonNull public Disposable schedulePeriodically(@NonNull java.lang.Runnable run, long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit)
Note to implementors: non-positive initialTime
and period
should be regarded as
non-delayed scheduling of the first and any subsequent executions.
run
- the Runnable to execute periodicallyinitialDelay
- time to wait before executing the action for the first time; non-positive values indicate
an non-delayed scheduleperiod
- the time interval to wait each time in between executing the action; non-positive values
indicate no delay between repeated schedulesunit
- the time unit of period
public long now(@NonNull java.util.concurrent.TimeUnit unit)
unit
- the time unit