Package rx.internal.schedulers
Class CachedThreadScheduler
- java.lang.Object
-
- rx.Scheduler
-
- rx.internal.schedulers.CachedThreadScheduler
-
- All Implemented Interfaces:
SchedulerLifecycle
public final class CachedThreadScheduler extends Scheduler implements SchedulerLifecycle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classCachedThreadScheduler.CachedWorkerPool(package private) static classCachedThreadScheduler.EventLoopWorker(package private) static classCachedThreadScheduler.ThreadWorker-
Nested classes/interfaces inherited from class rx.Scheduler
Scheduler.Worker
-
-
Field Summary
Fields Modifier and Type Field Description private static longKEEP_ALIVE_TIMEprivate static java.util.concurrent.TimeUnitKEEP_ALIVE_UNIT(package private) static CachedThreadScheduler.CachedWorkerPoolNONE(package private) java.util.concurrent.atomic.AtomicReference<CachedThreadScheduler.CachedWorkerPool>pool(package private) static CachedThreadScheduler.ThreadWorkerSHUTDOWN_THREADWORKER(package private) java.util.concurrent.ThreadFactorythreadFactory
-
Constructor Summary
Constructors Constructor Description CachedThreadScheduler(java.util.concurrent.ThreadFactory threadFactory)
-
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.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
-
KEEP_ALIVE_TIME
private static final long KEEP_ALIVE_TIME
- See Also:
- Constant Field Values
-
KEEP_ALIVE_UNIT
private static final java.util.concurrent.TimeUnit KEEP_ALIVE_UNIT
-
SHUTDOWN_THREADWORKER
static final CachedThreadScheduler.ThreadWorker SHUTDOWN_THREADWORKER
-
NONE
static final CachedThreadScheduler.CachedWorkerPool NONE
-
threadFactory
final java.util.concurrent.ThreadFactory threadFactory
-
pool
final java.util.concurrent.atomic.AtomicReference<CachedThreadScheduler.CachedWorkerPool> pool
-
-
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
-
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
-
-