Package rx.internal.schedulers
Class GenericScheduledExecutorService
java.lang.Object
rx.internal.schedulers.GenericScheduledExecutorService
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference<ScheduledExecutorService[]> static final GenericScheduledExecutorServiceprivate static final ScheduledExecutorService[]private static intWe don't use atomics with this because thread-assignment is random anyway.private static final ScheduledExecutorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ScheduledExecutorServiceReturns 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 Details
-
NONE
-
SHUTDOWN
-
INSTANCE
-
executor
-
roundRobin
private static int roundRobinWe don't use atomics with this because thread-assignment is random anyway.
-
-
Constructor Details
-
GenericScheduledExecutorService
private GenericScheduledExecutorService()
-
-
Method Details
-
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
Returns one of the single-threaded ScheduledExecutorService helper executors.- Returns:
ScheduledExecutorServicefor generic use.
-