Class ExecutorScheduler.ExecutorSchedulerWorker

  • All Implemented Interfaces:
    java.lang.Runnable, Subscription
    Enclosing class:
    ExecutorScheduler

    static final class ExecutorScheduler.ExecutorSchedulerWorker
    extends Scheduler.Worker
    implements java.lang.Runnable
    Worker that schedules tasks on the executor indirectly through a trampoline mechanism.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.concurrent.Executor executor  
      (package private) java.util.concurrent.ConcurrentLinkedQueue<ScheduledAction> queue  
      (package private) java.util.concurrent.ScheduledExecutorService service  
      (package private) CompositeSubscription tasks  
      (package private) java.util.concurrent.atomic.AtomicInteger wip  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecutorSchedulerWorker​(java.util.concurrent.Executor executor)  
    • Field Detail

      • executor

        final java.util.concurrent.Executor executor
      • queue

        final java.util.concurrent.ConcurrentLinkedQueue<ScheduledAction> queue
      • wip

        final java.util.concurrent.atomic.AtomicInteger wip
      • service

        final java.util.concurrent.ScheduledExecutorService service
    • Constructor Detail

      • ExecutorSchedulerWorker

        public ExecutorSchedulerWorker​(java.util.concurrent.Executor executor)
    • Method Detail

      • schedule

        public Subscription schedule​(Action0 action)
        Description copied from class: Scheduler.Worker
        Schedules an Action for execution.
        Specified by:
        schedule in class Scheduler.Worker
        Parameters:
        action - Action to schedule
        Returns:
        a subscription to be able to unsubscribe the action (unschedule it if not executed)
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • schedule

        public Subscription schedule​(Action0 action,
                                     long delayTime,
                                     java.util.concurrent.TimeUnit unit)
        Description copied from class: Scheduler.Worker
        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 Scheduler.Worker.schedule(rx.functions.Action0) was called.

        Specified by:
        schedule in class Scheduler.Worker
        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)
      • isUnsubscribed

        public boolean isUnsubscribed()
        Description copied from interface: Subscription
        Indicates whether this Subscription is currently unsubscribed.
        Specified by:
        isUnsubscribed in interface Subscription
        Returns:
        true if this Subscription is currently unsubscribed, false otherwise
      • unsubscribe

        public void unsubscribe()
        Description copied from interface: Subscription
        Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

        This allows unregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

        Specified by:
        unsubscribe in interface Subscription