Package rx.schedulers
Class TestScheduler
java.lang.Object
rx.Scheduler
rx.schedulers.TestScheduler
The
TestScheduler is useful for debugging. It allows you to test schedules of events by manually
advancing the clock at whatever pace you choose.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) final class(package private) static final classNested classes/interfaces inherited from class rx.Scheduler
Scheduler.Worker -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static long(package private) final Queue<TestScheduler.TimedAction> (package private) long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadvanceTimeBy(long delayTime, TimeUnit unit) Moves the Scheduler's clock forward by a specified amount of time.voidadvanceTimeTo(long delayTime, TimeUnit unit) Moves the Scheduler's clock to a particular moment in time.Retrieves or creates a newScheduler.Workerthat represents serial execution of actions.longnow()Gets the current time, in milliseconds, according to this Scheduler.voidTriggers any actions that have not yet been triggered and that are scheduled to be triggered at or before this Scheduler's present time.private voidtriggerActions(long targetTimeInNanos)
-
Field Details
-
queue
-
counter
static long counter -
time
long time
-
-
Constructor Details
-
TestScheduler
public TestScheduler()
-
-
Method Details
-
now
public long now()Description copied from class:SchedulerGets the current time, in milliseconds, according to this Scheduler. -
advanceTimeBy
Moves the Scheduler's clock forward by a specified amount of time.- Parameters:
delayTime- the amount of time to move the Scheduler's clock forwardunit- the units of time thatdelayTimeis expressed in
-
advanceTimeTo
Moves the Scheduler's clock to a particular moment in time.- Parameters:
delayTime- the point in time to move the Scheduler's clock tounit- the units of time thatdelayTimeis expressed in
-
triggerActions
public 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. -
triggerActions
private void triggerActions(long targetTimeInNanos) -
createWorker
Description copied from class:SchedulerRetrieves or creates a newScheduler.Workerthat represents serial execution of actions.When work is completed it should be unsubscribed using
Subscription.unsubscribe().Work on a
Scheduler.Workeris guaranteed to be sequential.- Specified by:
createWorkerin classScheduler- Returns:
- a Worker representing a serial queue of actions to be executed
-