Package rx.internal.schedulers
Class GenericScheduledExecutorService
- java.lang.Object
-
- rx.internal.schedulers.GenericScheduledExecutorService
-
- All Implemented Interfaces:
SchedulerLifecycle
public final class GenericScheduledExecutorService extends java.lang.Object implements SchedulerLifecycle
A defaultScheduledExecutorServicethat can be used for scheduling actions when aSchedulerimplementation doesn't have that ability.For example if a
Scheduleris given anExecutoror {ExecutorServiceinstead ofScheduledExecutorService.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
Schedulerimplementation. This means for example that you would not use this approach along withTrampolineSchedulerorImmediateScheduler.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ScheduledExecutorService[]>executorstatic GenericScheduledExecutorServiceINSTANCEprivate static java.util.concurrent.ScheduledExecutorService[]NONEprivate static introundRobinWe don't use atomics with this because thread-assignment is random anyway.private static java.util.concurrent.ScheduledExecutorServiceSHUTDOWN
-
Constructor Summary
Constructors Modifier Constructor Description privateGenericScheduledExecutorService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ScheduledExecutorServicegetInstance()Returns one of the single-threaded ScheduledExecutorService helper executors.voidshutdown()Instructs the Scheduler instance to stop threads and stop accepting tasks on any outstanding Workers.voidstart()Allows the Scheduler instance to start threads and accept tasks on them.
-
-
-
Field Detail
-
NONE
private static final java.util.concurrent.ScheduledExecutorService[] NONE
-
SHUTDOWN
private static final java.util.concurrent.ScheduledExecutorService SHUTDOWN
-
INSTANCE
public static final GenericScheduledExecutorService INSTANCE
-
executor
private final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.ScheduledExecutorService[]> executor
-
roundRobin
private static int roundRobin
We don't use atomics with this because thread-assignment is random anyway.
-
-
Method Detail
-
start
public void start()
Description copied from interface:SchedulerLifecycleAllows the Scheduler instance to start threads and accept tasks on them.Implementations should make sure the call is idempotent and threadsafe.
- Specified by:
startin interfaceSchedulerLifecycle
-
shutdown
public void shutdown()
Description copied from interface:SchedulerLifecycleInstructs 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:
shutdownin interfaceSchedulerLifecycle
-
getInstance
public static java.util.concurrent.ScheduledExecutorService getInstance()
Returns one of the single-threaded ScheduledExecutorService helper executors.- Returns:
ScheduledExecutorServicefor generic use.
-
-