TestScheduler is useful for debugging. It allows you to test schedules of events by manually
advancing the clock at whatever pace you choose.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| pack-priv class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static long | |
| pack-priv final Queue | |
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | advanceTimeBy(long
the amount of time to move the Scheduler's clock forward delayTime, TimeUnit the units of time that unit)delayTime is expressed inMoves the Scheduler's clock forward by a specified amount of time. |
| public void | advanceTimeTo(long
the point in time to move the Scheduler's clock to delayTime, TimeUnit the units of time that unit)delayTime is expressed inMoves the Scheduler's clock to a particular moment in time. |
| public Scheduler. | createWorker()
Implements abstract rx. Scheduler. that represents serial execution of actions.
|
| public long | now()
Overrides rx. |
| 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. |
| private void |
| counter | back to summary |
|---|---|
| pack-priv static long counter | |
| queue | back to summary |
|---|---|
| pack-priv final Queue<TestScheduler. | |
| time | back to summary |
|---|---|
| pack-priv long time | |
| TestScheduler | back to summary |
|---|---|
| public TestScheduler() | |
| advanceTimeBy | back to summary |
|---|---|
| public void advanceTimeBy(long delayTime, TimeUnit unit) Moves the Scheduler's clock forward by a specified amount of time.
| |
| advanceTimeTo | back to summary |
|---|---|
| public void advanceTimeTo(long delayTime, TimeUnit unit) Moves the Scheduler's clock to a particular moment in time.
| |
| createWorker | back to summary |
|---|---|
| public Scheduler. Implements abstract rx. Doc from rx. Retrieves or creates a new
When work is completed it should be unsubscribed using
Work on a | |
| now | back to summary |
|---|---|
| public long now() Overrides rx. Doc from rx. Gets the current time, in milliseconds, according to this Scheduler.
| |
| triggerActions | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| private void triggerActions(long targetTimeInNanos) | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(TestScheduler.
the first object to be compared. action1,the second object to be compared. action2Implements java. |
| CompareActionsByTime | back to summary |
|---|---|
| pack-priv CompareActionsByTime() | |
| compare | back to summary |
|---|---|
| public int compare(TestScheduler. Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| Modifier and Type | Field and Description |
|---|---|
| private final BooleanSubscription |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isUnsubscribed()
Implements rx. Subscription is currently unsubscribed.
|
| public long | now()
Overrides rx. |
| public long | |
| public Subscription | schedule(Action0
the Action to schedule action, long time to wait before executing the action; non-positive values indicate an non-delayed
schedule delayTime, TimeUnit the time unit of unit)delayTimeImplements abstract rx. |
| public Subscription | schedule(Action0
Action to schedule action)Implements abstract rx. |
| public Subscription | schedulePeriodically(Action0
the Action to execute periodically action, long time to wait before executing the action for the first time; non-positive values indicate
an non-delayed schedule initialDelay, long the time interval to wait each time in between executing the action; non-positive values
indicate no delay between repeated schedules period, TimeUnit the time unit of unit)periodOverrides rx. |
| public void | unsubscribe()
Implements rx. Subscriber that was registered when this Subscription
was received.
|
| s | back to summary |
|---|---|
| private final BooleanSubscription s | |
| InnerTestScheduler | back to summary |
|---|---|
| pack-priv InnerTestScheduler() | |
| isUnsubscribed | back to summary |
|---|---|
| public boolean isUnsubscribed() Implements rx. Doc from rx. Indicates whether this
| |
| now | back to summary |
|---|---|
| public long now() Overrides rx. Doc from rx. Gets the current time, in milliseconds, according to this Scheduler.
| |
| nowNanos | back to summary |
|---|---|
| public long nowNanos() Implements rx.
| |
| schedule | back to summary |
|---|---|
| public Subscription schedule(Action0 action, long delayTime, TimeUnit unit) Implements abstract rx. Doc from rx. Schedules an Action for execution at some point in the future.
Note to implementors: non-positive
| |
| schedule | back to summary |
|---|---|
| public Subscription schedule(Action0 action) Implements abstract rx. Doc from rx. Schedules an Action for execution.
| |
| schedulePeriodically | back to summary |
|---|---|
| public Subscription schedulePeriodically(Action0 action, long initialDelay, long period, TimeUnit unit) Overrides rx. Doc from rx. Schedules a cancelable action to be executed periodically. This default implementation schedules recursively and waits for actions to complete (instead of potentially executing long-running actions concurrently). Each scheduler that can do periodic scheduling in a better way should override this.
Note to implementors: non-positive
| |
| unsubscribe | back to summary |
|---|---|
| public void unsubscribe() Implements rx. Doc from rx. Stops the receipt of notifications on the
This allows deregistering an
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Action0 | |
| private final long | |
| pack-priv final Scheduler. | |
| pack-priv final long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| action | back to summary |
|---|---|
| pack-priv final Action0 action | |
| count | back to summary |
|---|---|
| private final long count | |
| scheduler | back to summary |
|---|---|
| pack-priv final Scheduler. | |
| time | back to summary |
|---|---|
| pack-priv final long time | |
| TimedAction | back to summary |
|---|---|
| pack-priv TimedAction(Scheduler. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |