Class GenericScheduledExecutorService

java.lang.Object
rx.internal.schedulers.GenericScheduledExecutorService
All Implemented Interfaces:
SchedulerLifecycle

public final class GenericScheduledExecutorService extends Object implements SchedulerLifecycle
A default ScheduledExecutorService that can be used for scheduling actions when a Scheduler implementation doesn't have that ability.

For example if a Scheduler is given an Executor or {ExecutorService instead of ScheduledExecutorService.

NOTE: No actual work should be done on tasks submitted to this executor. Submit a task with the appropriate delay which then in turn invokes the work asynchronously on the appropriate Scheduler implementation. This means for example that you would not use this approach along with TrampolineScheduler or ImmediateScheduler.

  • Field Details

  • Constructor Details

    • GenericScheduledExecutorService

      private GenericScheduledExecutorService()
  • Method Details

    • start

      public void start()
      Description copied from interface: SchedulerLifecycle
      Allows the Scheduler instance to start threads and accept tasks on them.

      Implementations should make sure the call is idempotent and threadsafe.

      Specified by:
      start in interface SchedulerLifecycle
    • shutdown

      public void shutdown()
      Description copied from interface: SchedulerLifecycle
      Instructs the Scheduler instance to stop threads and stop accepting tasks on any outstanding Workers.

      Implementations should make sure the call is idempotent and threadsafe.

      Specified by:
      shutdown in interface SchedulerLifecycle
    • getInstance

      public static ScheduledExecutorService getInstance()
      Returns one of the single-threaded ScheduledExecutorService helper executors.
      Returns:
      ScheduledExecutorService for generic use.