Package rx

Class Scheduler.Worker

java.lang.Object
rx.Scheduler.Worker
All Implemented Interfaces:
Subscription
Direct Known Subclasses:
CachedThreadScheduler.EventLoopWorker, EventLoopsScheduler.EventLoopWorker, ExecutorScheduler.ExecutorSchedulerWorker, ImmediateScheduler.InnerImmediateScheduler, NewThreadWorker, TestScheduler.InnerTestScheduler, TrampolineScheduler.InnerCurrentThreadScheduler
Enclosing class:
Scheduler

public abstract static class Scheduler.Worker extends Object implements Subscription
Sequential Scheduler for executing actions on a single thread or event loop.

Unsubscribing the Scheduler.Worker unschedules all outstanding work and allows resources cleanup.

  • Constructor Details

    • Worker

      public Worker()
  • Method Details

    • schedule

      public abstract Subscription schedule(Action0 action)
      Schedules an Action for execution.
      Parameters:
      action - Action to schedule
      Returns:
      a subscription to be able to unsubscribe the action (unschedule it if not executed)
    • schedule

      public abstract Subscription schedule(Action0 action, long delayTime, TimeUnit unit)
      Schedules an Action for execution at some point in the future.

      Note to implementors: non-positive delayTime should be regarded as undelayed schedule, i.e., as if the schedule(rx.functions.Action0) was called.

      Parameters:
      action - the Action to schedule
      delayTime - time to wait before executing the action; non-positive values indicate an undelayed schedule
      unit - the time unit of delayTime
      Returns:
      a subscription to be able to unsubscribe the action (unschedule it if not executed)
    • schedulePeriodically

      public Subscription schedulePeriodically(Action0 action, long initialDelay, long period, TimeUnit unit)
      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 initialTime and period should be regarded as undelayed scheduling of the first and any subsequent executions.

      Parameters:
      action - the Action to execute periodically
      initialDelay - time to wait before executing the action for the first time; non-positive values indicate an undelayed schedule
      period - the time interval to wait each time in between executing the action; non-positive values indicate no delay between repeated schedules
      unit - the time unit of period
      Returns:
      a subscription to be able to unsubscribe the action (unschedule it if not executed)
    • now

      public long now()
      Gets the current time, in milliseconds, according to this Scheduler.
      Returns:
      the scheduler's notion of current absolute time in milliseconds