Top Description Inners Fields Constructors Methods
rx.internal.schedulers

public final Class TrampolineScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.PriorityBlockingQueue, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, rx.Scheduler, .Subscription, rx.functions.Action0, rx.subscriptions.BooleanSubscription, .Subscriptions

Schedules work on the current thread but does not execute immediately. Work is put in a queue and executed after the current unit of work is completed.

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
public static final TrampolineScheduler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int
compare(int x, int y)

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

INSTANCEback to summary
public static final TrampolineScheduler INSTANCE

Constructor Detail

TrampolineSchedulerback to summary
private TrampolineScheduler()

Method Detail

compareback to summary
pack-priv static int compare(int x, int y)
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 TrampolineScheduler.InnerCurrentThreadScheduler

extends Worker
implements Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicInteger
private final BooleanSubscription
pack-priv final PriorityBlockingQueue<TrampolineScheduler.TimedAction>
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private Subscription
enqueue(Action0 action, long execTime)

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

counterback to summary
pack-priv final AtomicInteger counter
innerSubscriptionback to summary
private final BooleanSubscription innerSubscription
queueback to summary
pack-priv final PriorityBlockingQueue<TrampolineScheduler.TimedAction> queue
wipback to summary
private final AtomicInteger wip

Constructor Detail

InnerCurrentThreadSchedulerback to summary
pack-priv InnerCurrentThreadScheduler()

Method Detail

enqueueback to summary
private Subscription enqueue(Action0 action, long execTime)
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(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 TrampolineScheduler.TimedAction

extends Object
implements Comparable<TrampolineScheduler.TimedAction>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
pack-priv final Action0
pack-priv final int
pack-priv final Long

Constructor Summary

AccessConstructor and Description
pack-priv
TimedAction(Action0 action, Long execTime, int count)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(TrampolineScheduler.TimedAction
the object to be compared.
that
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionback to summary
pack-priv final Action0 action
countback to summary
pack-priv final int count
execTimeback to summary
pack-priv final Long execTime

Constructor Detail

TimedActionback to summary
pack-priv TimedAction(Action0 action, Long execTime, int count)

Method Detail

compareToback to summary
public int compareTo(TrampolineScheduler.TimedAction that)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
that:TrampolineScheduler.TimedAction

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override