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 GenericScheduledExecutorService
private static final ScheduledExecutorService[]
private static int
We don't use atomics with this because thread-assignment is random anyway.private static final ScheduledExecutorService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ScheduledExecutorService
Returns one of the single-threaded ScheduledExecutorService helper executors.void
shutdown()
Instructs the Scheduler instance to stop threads and stop accepting tasks on any outstanding Workers.void
start()
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: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 interfaceSchedulerLifecycle
-
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 interfaceSchedulerLifecycle
-
getInstance
Returns one of the single-threaded ScheduledExecutorService helper executors.- Returns:
ScheduledExecutorService
for generic use.
-