public final class TestScheduler extends Scheduler
Scheduler.Worker
Constructor and Description |
---|
TestScheduler()
Creates a new TestScheduler with initial virtual time of zero.
|
TestScheduler(long delayTime,
TimeUnit unit)
Creates a new TestScheduler with the specified initial virtual time.
|
Modifier and Type | Method and Description |
---|---|
void |
advanceTimeBy(long delayTime,
TimeUnit unit)
Moves the Scheduler's clock forward by a specified amount of time.
|
void |
advanceTimeTo(long delayTime,
TimeUnit unit)
Moves the Scheduler's clock to a particular moment in time.
|
Scheduler.Worker |
createWorker()
Retrieves or creates a new
Scheduler.Worker that represents sequential execution of actions. |
long |
now(TimeUnit unit)
Returns the 'current time' of the Scheduler in the specified time unit.
|
void |
triggerActions()
Triggers any actions that have not yet been triggered and that are scheduled to be triggered at or
before this Scheduler's present time.
|
clockDriftTolerance, scheduleDirect, scheduleDirect, schedulePeriodicallyDirect, shutdown, start, when
public TestScheduler()
public TestScheduler(long delayTime, TimeUnit unit)
delayTime
- the point in time to move the Scheduler's clock tounit
- the units of time that delayTime
is expressed inpublic long now(@NonNull TimeUnit unit)
Scheduler
public void advanceTimeBy(long delayTime, TimeUnit unit)
delayTime
- the amount of time to move the Scheduler's clock forwardunit
- the units of time that delayTime
is expressed inpublic void advanceTimeTo(long delayTime, TimeUnit unit)
delayTime
- the point in time to move the Scheduler's clock tounit
- the units of time that delayTime
is expressed inpublic void triggerActions()
@NonNull public Scheduler.Worker createWorker()
Scheduler
Scheduler.Worker
that represents sequential execution of actions.
When work is completed, the Worker
instance should be released
by calling Disposable.dispose()
to avoid potential resource leaks in the
underlying task-execution scheme.
Work on a Scheduler.Worker
is guaranteed to be sequential and non-overlapping.
createWorker
in class Scheduler