Top Description Inners Fields Constructors Methods
rx.internal.schedulers

public final Class ExecutorScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.*, java.util.concurrent.atomic.AtomicInteger, rx.*, rx.functions.Action0, rx.plugins.RxJavaHooks, rx.subscriptions.*

Scheduler that wraps an Executor instance and establishes the Scheduler contract upon it.

Note that thread-hopping is unavoidable with this kind of Scheduler as we don't know about the underlying threading behavior of the executor.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ExecutorScheduler.ExecutorSchedulerWorker

Worker that schedules tasks on the executor indirectly through a trampoline mechanism.

Field Summary

Modifier and TypeField and Description
pack-priv final Executor

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.
Inherited from rx.Scheduler:
nowwhen

Field Detail

executorback to summary
pack-priv final Executor executor

Constructor Detail

ExecutorSchedulerback to summary
public ExecutorScheduler(Executor executor)

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
rx.internal.schedulers back to summary

pack-priv final Class ExecutorScheduler.ExecutorSchedulerWorker

extends Worker
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Worker that schedules tasks on the executor indirectly through a trampoline mechanism.

Field Summary

Modifier and TypeField and Description
pack-priv final Executor
pack-priv final ConcurrentLinkedQueue<ScheduledAction>
pack-priv final ScheduledExecutorService
pack-priv final CompositeSubscription
pack-priv final AtomicInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public Subscription
schedule(Action0
Action to schedule
action
)

Implements abstract rx.Scheduler.Worker.schedule.

Schedules an Action for execution.
public Subscription
schedule(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

executorback to summary
pack-priv final Executor executor
queueback to summary
pack-priv final ConcurrentLinkedQueue<ScheduledAction> queue
serviceback to summary
pack-priv final ScheduledExecutorService service
tasksback to summary
pack-priv final CompositeSubscription tasks
wipback to summary
pack-priv final AtomicInteger wip

Constructor Detail

ExecutorSchedulerWorkerback to summary
public ExecutorSchedulerWorker(Executor executor)

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
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

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(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