Class EventLoopsScheduler

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

public final class EventLoopsScheduler extends Scheduler implements SchedulerLifecycle
  • Field Details

  • Constructor Details

    • EventLoopsScheduler

      public EventLoopsScheduler(ThreadFactory threadFactory)
      Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.
      Parameters:
      threadFactory - the factory to use with the executors
  • Method Details

    • createWorker

      public Scheduler.Worker createWorker()
      Description copied from class: Scheduler
      Retrieves or creates a new Scheduler.Worker that represents serial execution of actions.

      When work is completed it should be unsubscribed using Subscription.unsubscribe().

      Work on a Scheduler.Worker is guaranteed to be sequential.

      Specified by:
      createWorker in class Scheduler
      Returns:
      a Worker representing a serial queue of actions to be executed
    • 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
    • scheduleDirect

      public Subscription scheduleDirect(Action0 action)
      Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.
      Parameters:
      action - the action to schedule
      Returns:
      the subscription