Package rx.internal.schedulers
Class EventLoopsScheduler
java.lang.Object
rx.Scheduler
rx.internal.schedulers.EventLoopsScheduler
- All Implemented Interfaces:
SchedulerLifecycle
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
(package private) static final class
(package private) static final class
Nested classes/interfaces inherited from class rx.Scheduler
Scheduler.Worker
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
Key to setting the maximum number of computation scheduler threads.(package private) static final int
The maximum number of computation scheduler threads.(package private) static final EventLoopsScheduler.FixedSchedulerPool
This will indicate no pool is active.(package private) final AtomicReference
<EventLoopsScheduler.FixedSchedulerPool> (package private) static final EventLoopsScheduler.PoolWorker
(package private) final ThreadFactory
-
Constructor Summary
ConstructorsConstructorDescriptionEventLoopsScheduler
(ThreadFactory threadFactory) Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves or creates a newScheduler.Worker
that represents serial execution of actions.scheduleDirect
(Action0 action) Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.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
-
KEY_MAX_THREADS
Key to setting the maximum number of computation scheduler threads. Zero or less is interpreted as use available. Capped by available.- See Also:
-
MAX_THREADS
static final int MAX_THREADSThe maximum number of computation scheduler threads. -
SHUTDOWN_WORKER
-
NONE
This will indicate no pool is active. -
threadFactory
-
pool
-
-
Constructor Details
-
EventLoopsScheduler
Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.- Parameters:
threadFactory
- the factory to use with the executors
-
-
Method Details
-
createWorker
Description copied from class:Scheduler
Retrieves or creates a newScheduler.Worker
that represents serial execution of actions.When work is completed it should be unsubscribed using
Subscription.unsubscribe()
.Work on a
Scheduler.Worker
is guaranteed to be sequential.- Specified by:
createWorker
in classScheduler
- Returns:
- a Worker representing a serial queue of actions to be executed
-
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
-
scheduleDirect
Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.- Parameters:
action
- the action to schedule- Returns:
- the subscription
-