Package rx.internal.schedulers
Class EventLoopsScheduler
- java.lang.Object
-
- rx.Scheduler
-
- rx.internal.schedulers.EventLoopsScheduler
-
- All Implemented Interfaces:
SchedulerLifecycle
public final class EventLoopsScheduler extends Scheduler implements SchedulerLifecycle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classEventLoopsScheduler.EventLoopWorker(package private) static classEventLoopsScheduler.FixedSchedulerPool(package private) static classEventLoopsScheduler.PoolWorker-
Nested classes/interfaces inherited from class rx.Scheduler
Scheduler.Worker
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringKEY_MAX_THREADSKey to setting the maximum number of computation scheduler threads.(package private) static intMAX_THREADSThe maximum number of computation scheduler threads.(package private) static EventLoopsScheduler.FixedSchedulerPoolNONEThis will indicate no pool is active.(package private) java.util.concurrent.atomic.AtomicReference<EventLoopsScheduler.FixedSchedulerPool>pool(package private) static EventLoopsScheduler.PoolWorkerSHUTDOWN_WORKER(package private) java.util.concurrent.ThreadFactorythreadFactory
-
Constructor Summary
Constructors Constructor Description EventLoopsScheduler(java.util.concurrent.ThreadFactory threadFactory)Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Scheduler.WorkercreateWorker()Retrieves or creates a newScheduler.Workerthat represents serial execution of actions.SubscriptionscheduleDirect(Action0 action)Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.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
-
KEY_MAX_THREADS
static final java.lang.String 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:
- Constant Field Values
-
MAX_THREADS
static final int MAX_THREADS
The maximum number of computation scheduler threads.
-
SHUTDOWN_WORKER
static final EventLoopsScheduler.PoolWorker SHUTDOWN_WORKER
-
NONE
static final EventLoopsScheduler.FixedSchedulerPool NONE
This will indicate no pool is active.
-
threadFactory
final java.util.concurrent.ThreadFactory threadFactory
-
pool
final java.util.concurrent.atomic.AtomicReference<EventLoopsScheduler.FixedSchedulerPool> pool
-
-
Constructor Detail
-
EventLoopsScheduler
public EventLoopsScheduler(java.util.concurrent.ThreadFactory threadFactory)
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 Detail
-
createWorker
public Scheduler.Worker createWorker()
Description copied from class:SchedulerRetrieves or creates a newScheduler.Workerthat represents serial execution of actions.When work is completed it should be unsubscribed using
Subscription.unsubscribe().Work on a
Scheduler.Workeris guaranteed to be sequential.- Specified by:
createWorkerin classScheduler- Returns:
- a Worker representing a serial queue of actions to be executed
-
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
-
scheduleDirect
public Subscription scheduleDirect(Action0 action)
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
-
-