Top Inners Fields Constructors Methods
rx.internal.schedulers

public final Class CachedThreadScheduler

extends Scheduler
implements SchedulerLifecycle
Class Inheritance
All Implemented Interfaces
rx.internal.schedulers.SchedulerLifecycle
Imports
java.util.concurrent.*, java.util.concurrent.atomic.*, rx.*, rx.functions.Action0, rx.internal.util.RxThreadFactory, rx.subscriptions.*

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final long
private static final TimeUnit
pack-priv static final CachedThreadScheduler.CachedWorkerPool
pack-priv final AtomicReference<CachedThreadScheduler.CachedWorkerPool>
pack-priv static final CachedThreadScheduler.ThreadWorker
pack-priv final ThreadFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Scheduler.Worker
createWorker()

Implements abstract rx.Scheduler.createWorker.

Retrieves or creates a new Scheduler.Worker that represents serial execution of actions.
public void
shutdown()

Implements rx.internal.schedulers.SchedulerLifecycle.shutdown.

Instructs the Scheduler instance to stop threads and stop accepting tasks on any outstanding Workers.
public void
start()

Implements rx.internal.schedulers.SchedulerLifecycle.start.

Allows the Scheduler instance to start threads and accept tasks on them.
Inherited from rx.Scheduler:
nowwhen

Field Detail

KEEP_ALIVE_TIMEback to summary
private static final long KEEP_ALIVE_TIME
KEEP_ALIVE_UNITback to summary
private static final TimeUnit KEEP_ALIVE_UNIT
NONEback to summary
pack-priv static final CachedThreadScheduler.CachedWorkerPool NONE
poolback to summary
pack-priv final AtomicReference<CachedThreadScheduler.CachedWorkerPool> pool
SHUTDOWN_THREADWORKERback to summary
pack-priv static final CachedThreadScheduler.ThreadWorker SHUTDOWN_THREADWORKER
threadFactoryback to summary
pack-priv final ThreadFactory threadFactory

Constructor Detail

CachedThreadSchedulerback to summary
public CachedThreadScheduler(ThreadFactory threadFactory)

Method Detail

createWorkerback to summary
public Scheduler.Worker createWorker()

Implements abstract rx.Scheduler.createWorker.

Doc from rx.Scheduler.createWorker.

Retrieves or creates a new Scheduler.Worker that represents serial execution of actions.

When work is completed it should be unsubscribed using Scheduler.Worker#unsubscribe().

Work on a Scheduler.Worker is guaranteed to be sequential.

Returns:Scheduler.Worker

a Worker representing a serial queue of actions to be executed

Annotations
@Override
shutdownback to summary
public void shutdown()

Implements rx.internal.schedulers.SchedulerLifecycle.shutdown.

Doc from rx.internal.schedulers.SchedulerLifecycle.shutdown.

Instructs the Scheduler instance to stop threads and stop accepting tasks on any outstanding Workers.

Implementations should make sure the call is idempotent and thread-safe.

Annotations
@Override
startback to summary
public void start()

Implements rx.internal.schedulers.SchedulerLifecycle.start.

Doc from rx.internal.schedulers.SchedulerLifecycle.start.

Allows the Scheduler instance to start threads and accept tasks on them.

Implementations should make sure the call is idempotent and thread-safe.

Annotations
@Override
rx.internal.schedulers back to summary

pack-priv final Class CachedThreadScheduler.CachedWorkerPool

extends Object
Class Inheritance
  • java.lang.Object
  • rx.internal.schedulers.CachedThreadScheduler.CachedWorkerPool

Field Summary

Modifier and TypeField and Description
private final CompositeSubscription
private final ScheduledExecutorService
private final Future<?>
private final ConcurrentLinkedQueue<CachedThreadScheduler.ThreadWorker>
private final long
private final ThreadFactory

Constructor Summary

AccessConstructor and Description
pack-priv
CachedWorkerPool(final ThreadFactory threadFactory, long keepAliveTime, TimeUnit unit)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv CachedThreadScheduler.ThreadWorker
get()

pack-priv long
now()

pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allWorkersback to summary
private final CompositeSubscription allWorkers
evictorServiceback to summary
private final ScheduledExecutorService evictorService
evictorTaskback to summary
private final Future<?> evictorTask
expiringWorkerQueueback to summary
private final ConcurrentLinkedQueue<CachedThreadScheduler.ThreadWorker> expiringWorkerQueue
keepAliveTimeback to summary
private final long keepAliveTime
threadFactoryback to summary
private final ThreadFactory threadFactory

Constructor Detail

CachedWorkerPoolback to summary
pack-priv CachedWorkerPool(final ThreadFactory threadFactory, long keepAliveTime, TimeUnit unit)

Method Detail

evictExpiredWorkersback to summary
pack-priv void evictExpiredWorkers()
getback to summary
pack-priv CachedThreadScheduler.ThreadWorker get()
nowback to summary
pack-priv long now()
releaseback to summary
pack-priv void release(CachedThreadScheduler.ThreadWorker threadWorker)
shutdownback to summary
pack-priv void shutdown()
rx.internal.schedulers back to summary

pack-priv final Class CachedThreadScheduler.EventLoopWorker

extends Worker
implements Action0
Class Inheritance
All Implemented Interfaces
rx.functions.Action0, rx.functions.Action, rx.functions.Function

Field Summary

Modifier and TypeField and Description
private final CompositeSubscription
pack-priv final AtomicBoolean
private final CachedThreadScheduler.CachedWorkerPool
private final CachedThreadScheduler.ThreadWorker

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public Subscription
schedule(Action0
Action to schedule
action
)

Implements abstract rx.Scheduler.Worker.schedule.

Schedules an Action for execution.
public Subscription
schedule(final Action0
the Action to schedule
action
,
long
time to wait before executing the action; non-positive values indicate an non-delayed schedule
delayTime
,
TimeUnit
the time unit of delayTime
unit
)

Implements abstract rx.Scheduler.Worker.schedule.

Schedules an Action for execution at some point in the future.
public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from rx.Scheduler.Worker:
nowschedulePeriodically

Field Detail

innerSubscriptionback to summary
private final CompositeSubscription innerSubscription
onceback to summary
pack-priv final AtomicBoolean once
poolback to summary
private final CachedThreadScheduler.CachedWorkerPool pool
threadWorkerback to summary
private final CachedThreadScheduler.ThreadWorker threadWorker

Constructor Detail

EventLoopWorkerback to summary
pack-priv EventLoopWorker(CachedThreadScheduler.CachedWorkerPool pool)

Method Detail

callback to summary
public void call()

Implements rx.functions.Action0.call.

Annotations
@Override
isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
scheduleback to summary
public Subscription schedule(Action0 action)

Implements abstract rx.Scheduler.Worker.schedule.

Doc from rx.Scheduler.Worker.schedule.

Schedules an Action for execution.

Parameters
action:Action0

Action to schedule

Returns:Subscription

a subscription to be able to prevent or cancel the execution of the action

Annotations
@Override
scheduleback to summary
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit)

Implements abstract rx.Scheduler.Worker.schedule.

Doc from rx.Scheduler.Worker.schedule.

Schedules an Action for execution at some point in the future.

Note to implementors: non-positive delayTime should be regarded as non-delayed schedule, i.e., as if the schedule(rx.functions.Action0) was called.

Parameters
action:Action0

the Action to schedule

delayTime:long

time to wait before executing the action; non-positive values indicate an non-delayed schedule

unit:TimeUnit

the time unit of delayTime

Returns:Subscription

a subscription to be able to prevent or cancel the execution of the action

Annotations
@Override
unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override
rx.internal.schedulers back to summary

pack-priv final Class CachedThreadScheduler.ThreadWorker

extends NewThreadWorker
Class Inheritance

Field Summary

Modifier and TypeField and Description
private long
Inherited from rx.internal.schedulers.NewThreadWorker:
isUnsubscribedPURGE_FREQUENCY

Constructor Summary

AccessConstructor and Description
pack-priv
ThreadWorker(ThreadFactory threadFactory)

Method Summary

Modifier and TypeMethod and Description
public long
public void
setExpirationTime(long expirationTime)

Inherited from rx.internal.schedulers.NewThreadWorker:
deregisterExecutorfindSetRemoveOnCancelPolicyMethodisUnsubscribedpurgeExecutorsregisterExecutorscheduleschedulescheduleActualscheduleActualscheduleActualtryEnableCancelPolicyunsubscribe

Field Detail

expirationTimeback to summary
private long expirationTime

Constructor Detail

ThreadWorkerback to summary
pack-priv ThreadWorker(ThreadFactory threadFactory)

Method Detail

getExpirationTimeback to summary
public long getExpirationTime()
setExpirationTimeback to summary
public void setExpirationTime(long expirationTime)