Package rx.schedulers

Class TestScheduler


  • public class TestScheduler
    extends Scheduler
    The TestScheduler is useful for debugging. It allows you to test schedules of events by manually advancing the clock at whatever pace you choose.
    • Constructor Detail

      • TestScheduler

        public TestScheduler()
    • Method Detail

      • now

        public long now()
        Description copied from class: Scheduler
        Gets the current time, in milliseconds, according to this Scheduler.
        Overrides:
        now in class Scheduler
        Returns:
        the scheduler's notion of current absolute time in milliseconds
      • advanceTimeBy

        public void advanceTimeBy​(long delayTime,
                                  java.util.concurrent.TimeUnit unit)
        Moves the Scheduler's clock forward by a specified amount of time.
        Parameters:
        delayTime - the amount of time to move the Scheduler's clock forward
        unit - the units of time that delayTime is expressed in
      • advanceTimeTo

        public void advanceTimeTo​(long delayTime,
                                  java.util.concurrent.TimeUnit unit)
        Moves the Scheduler's clock to a particular moment in time.
        Parameters:
        delayTime - the point in time to move the Scheduler's clock to
        unit - the units of time that delayTime is 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)