Top Inners Fields Constructors Methods
rx.internal.schedulers

public final Class EventLoopsScheduler

extends Scheduler
implements SchedulerLifecycle
Class Inheritance
All Implemented Interfaces
rx.internal.schedulers.SchedulerLifecycle
Imports
java.util.concurrent.*, java.util.concurrent.atomic.AtomicReference, rx.*, rx.functions.Action0, rx.internal.util.*, 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
pack-priv static final String
KEY_MAX_THREADS

Key to setting the maximum number of computation scheduler threads.

pack-priv static final int
MAX_THREADS

The maximum number of computation scheduler threads.

pack-priv static final EventLoopsScheduler.FixedSchedulerPool
NONE

This will indicate no pool is active.

pack-priv final AtomicReference<EventLoopsScheduler.FixedSchedulerPool>
pack-priv static final EventLoopsScheduler.PoolWorker
pack-priv final ThreadFactory

Constructor Summary

AccessConstructor and Description
public
EventLoopsScheduler(ThreadFactory
the factory to use with the executors
threadFactory
)

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

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 Subscription

Returns:

the subscription
scheduleDirect
(Action0
the action to schedule
action
)

Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.

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

KEY_MAX_THREADSback to summary
pack-priv static final 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.

MAX_THREADSback to summary
pack-priv static final int MAX_THREADS

The maximum number of computation scheduler threads.

NONEback to summary
pack-priv static final EventLoopsScheduler.FixedSchedulerPool NONE

This will indicate no pool is active.

poolback to summary
pack-priv final AtomicReference<EventLoopsScheduler.FixedSchedulerPool> pool
SHUTDOWN_WORKERback to summary
pack-priv static final EventLoopsScheduler.PoolWorker SHUTDOWN_WORKER
threadFactoryback to summary
pack-priv final ThreadFactory threadFactory

Constructor Detail

EventLoopsSchedulerback to summary
public EventLoopsScheduler(ThreadFactory threadFactory)

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

Parameters
threadFactory:ThreadFactory

the factory to use with the executors

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
scheduleDirectback to summary
public Subscription scheduleDirect(Action0 action)

Schedules the action directly on one of the event loop workers without the additional infrastructure and checking.

Parameters
action:Action0

the action to schedule

Returns:Subscription

the subscription

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 EventLoopsScheduler.EventLoopWorker

extends Worker
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SubscriptionList
private final EventLoopsScheduler.PoolWorker
private final SubscriptionList
private final CompositeSubscription

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public Subscription
schedule(final 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

bothback to summary
private final SubscriptionList both
poolWorkerback to summary
private final EventLoopsScheduler.PoolWorker poolWorker
serialback to summary
private final SubscriptionList serial
timedback to summary
private final CompositeSubscription timed

Constructor Detail

EventLoopWorkerback to summary
pack-priv EventLoopWorker(EventLoopsScheduler.PoolWorker poolWorker)

Method Detail

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(final 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 EventLoopsScheduler.FixedSchedulerPool

extends Object
Class Inheritance
  • java.lang.Object
  • rx.internal.schedulers.EventLoopsScheduler.FixedSchedulerPool

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final EventLoopsScheduler.PoolWorker[]
pack-priv long
n

Constructor Summary

AccessConstructor and Description
pack-priv
FixedSchedulerPool(ThreadFactory threadFactory, int maxThreads)

Method Summary

Modifier and TypeMethod and Description
public EventLoopsScheduler.PoolWorker
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

coresback to summary
pack-priv final int cores
eventLoopsback to summary
pack-priv final EventLoopsScheduler.PoolWorker[] eventLoops
nback to summary
pack-priv long n

Constructor Detail

FixedSchedulerPoolback to summary
pack-priv FixedSchedulerPool(ThreadFactory threadFactory, int maxThreads)

Method Detail

getEventLoopback to summary
public EventLoopsScheduler.PoolWorker getEventLoop()
shutdownback to summary
public void shutdown()
rx.internal.schedulers back to summary

pack-priv final Class EventLoopsScheduler.PoolWorker

extends NewThreadWorker
Class Inheritance

Field Summary

Inherited from rx.internal.schedulers.NewThreadWorker:
isUnsubscribedPURGE_FREQUENCY

Constructor Summary

AccessConstructor and Description
pack-priv
PoolWorker(ThreadFactory threadFactory)

Method Summary

Inherited from rx.internal.schedulers.NewThreadWorker:
deregisterExecutorfindSetRemoveOnCancelPolicyMethodisUnsubscribedpurgeExecutorsregisterExecutorscheduleschedulescheduleActualscheduleActualscheduleActualtryEnableCancelPolicyunsubscribe

Constructor Detail

PoolWorkerback to summary
pack-priv PoolWorker(ThreadFactory threadFactory)