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 class
CachedThreadScheduler.CachedWorkerPool
(package private) static class
CachedThreadScheduler.EventLoopWorker
(package private) static class
CachedThreadScheduler.ThreadWorker
-
Nested classes/interfaces inherited from class rx.Scheduler
Scheduler.Worker
-
-
Field Summary
Fields Modifier and Type Field Description private static long
KEEP_ALIVE_TIME
private static java.util.concurrent.TimeUnit
KEEP_ALIVE_UNIT
(package private) static CachedThreadScheduler.CachedWorkerPool
NONE
(package private) java.util.concurrent.atomic.AtomicReference<CachedThreadScheduler.CachedWorkerPool>
pool
(package private) static CachedThreadScheduler.ThreadWorker
SHUTDOWN_THREADWORKER
(package private) java.util.concurrent.ThreadFactory
threadFactory
-
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.Worker
createWorker()
Retrieves or creates a newScheduler.Worker
that represents serial execution of actions.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 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: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
-
createWorker
public Scheduler.Worker 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
-
-