Package 

Class NewThreadWorker

  • All Implemented Interfaces:
    com.tds.common.reactor.Subscription

    
    public class NewThreadWorker
    extends Scheduler.Worker implements Subscription
                        

    Represents a Scheduler.Worker that runs on its own unique and single-threaded ScheduledExecutorService created via Executors.

    • Constructor Detail

    • Method Detail

      • isUnsubscribed

         boolean isUnsubscribed()

        Indicates whether this {@code Subscription} is currently unsubscribed.

      • registerExecutor

         static void registerExecutor(ScheduledThreadPoolExecutor service)

        Registers the given executor service and starts the purge thread if not already started.

        {@code public} visibility reason: called from other package(s) within RxJava

        Parameters:
        service - a scheduled thread pool executor instance
      • deregisterExecutor

         static void deregisterExecutor(ScheduledExecutorService service)

        Deregisters the executor service.

        {@code public} visibility reason: called from other package(s) within RxJava

        Parameters:
        service - a scheduled thread pool executor instance
      • tryEnableCancelPolicy

         static boolean tryEnableCancelPolicy(ScheduledExecutorService executor)

        Tries to enable the Java 7+ setRemoveOnCancelPolicy.

        {@code public} visibility reason: called from other package(s) within RxJava.If the method returns false, the registerExecutor maybe called to enable the backup option of purging the executors.

        Parameters:
        executor - the executor to call setRemoveOnCancelPolicy if available.
      • schedule

         Subscription schedule(Action0 action, long delayTime, TimeUnit unit)

        Schedules an Action for execution at some point in the future.

        Note to implementors: non-positive {@code delayTime} should be regarded as non-delayed schedule, i.e.,as if the schedule was called.

        Parameters:
        action - the Action to schedule
        delayTime - time to wait before executing the action; non-positive values indicate an non-delayedschedule
        unit - the time unit of {@code delayTime}
      • scheduleActual

         ScheduledAction scheduleActual(Action0 action, long delayTime, TimeUnit unit)

        Schedules the given action by wrapping it into a ScheduledAction on theunderlying ExecutorService, returning the ScheduledAction.

        Parameters:
        action - the action to wrap and schedule
        delayTime - the delay in execution
        unit - the time unit of the delay
      • unsubscribe

         void unsubscribe()

        Stops the receipt of notifications on the Subscriber that was registered when this Subscriptionwas received.

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