public class TestScheduler extends Scheduler
TestScheduler
is useful for debugging. It allows you to test schedules of events by manually
advancing the clock at whatever pace you choose.Scheduler.Worker
Constructor and Description |
---|
TestScheduler() |
Modifier and Type | Method and Description |
---|---|
void |
advanceTimeBy(long delayTime,
java.util.concurrent.TimeUnit unit)
Moves the Scheduler's clock forward by a specified amount of time.
|
void |
advanceTimeTo(long delayTime,
java.util.concurrent.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 serial execution of actions. |
long |
now()
Gets the current time, in milliseconds, according to this Scheduler.
|
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.
|
public long now()
Scheduler
public void advanceTimeBy(long delayTime, java.util.concurrent.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, java.util.concurrent.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()
public Scheduler.Worker createWorker()
Scheduler
Scheduler.Worker
that represents serial execution of actions.
When work is completed it should be unsubscribed using Subscription.unsubscribe()
.
Work on a Scheduler.Worker
is guaranteed to be sequential.
createWorker
in class Scheduler