Top Description Inners Fields Constructors Methods
io.reactivex.internal.schedulers

public final Class TrampolineScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.*, java.util.concurrent.atomic.AtomicInteger, io.reactivex.Scheduler, io.reactivex.annotations.NonNull, io.reactivex.disposables.*, io.reactivex.internal.disposables.EmptyDisposable, io.reactivex.internal.functions.ObjectHelper, io.reactivex.plugins.RxJavaPlugins

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
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final TrampolineScheduler

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

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

Implements abstract io.reactivex.Scheduler.createWorker.

Retrieves or creates a new Scheduler.Worker that represents sequential execution of actions.
public static TrampolineScheduler
public Disposable
scheduleDirect(Runnable
the task to execute
run
)

Overrides io.reactivex.Scheduler.scheduleDirect.

Schedules the given task on this Scheduler without any time delay.
public Disposable
scheduleDirect(Runnable
the task to schedule
run
,
long
the delay amount, non-positive values indicate non-delayed scheduling
delay
,
TimeUnit
the unit of measure of the delay amount
unit
)

Overrides io.reactivex.Scheduler.scheduleDirect.

Schedules the execution of the given task with the given time delay.
Inherited from io.reactivex.Scheduler:
clockDriftTolerancenowschedulePeriodicallyDirectshutdownstartwhen

Field Detail

INSTANCEback to summary
private static final TrampolineScheduler INSTANCE

Constructor Detail

TrampolineSchedulerback to summary
pack-priv TrampolineScheduler()

Method Detail

createWorkerback to summary
public Scheduler.Worker createWorker()

Implements abstract io.reactivex.Scheduler.createWorker.

Doc from io.reactivex.Scheduler.createWorker.

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

When work is completed, the Worker instance should be released by calling Scheduler.Worker#dispose() to avoid potential resource leaks in the underlying task-execution scheme.

Work on a Scheduler.Worker is guaranteed to be sequential and non-overlapping.

Returns:Scheduler.Worker

a Worker representing a serial queue of actions to be executed

Annotations
@NonNull
@Override
instanceback to summary
public static TrampolineScheduler instance()
scheduleDirectback to summary
public Disposable scheduleDirect(Runnable run)

Overrides io.reactivex.Scheduler.scheduleDirect.

Doc from io.reactivex.Scheduler.scheduleDirect.

Schedules the given task on this Scheduler without any time delay.

This method is safe to be called from multiple threads but there are no ordering or non-overlapping guarantees between tasks.

Parameters
run:Runnable

the task to execute

Returns:Disposable

the Disposable instance that let's one cancel this particular task.

Annotations
@NonNull
@Override
scheduleDirectback to summary
public Disposable scheduleDirect(Runnable run, long delay, TimeUnit unit)

Overrides io.reactivex.Scheduler.scheduleDirect.

Doc from io.reactivex.Scheduler.scheduleDirect.

Schedules the execution of the given task with the given time delay.

This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.

Parameters
run:Runnable

the task to schedule

delay:long

the delay amount, non-positive values indicate non-delayed scheduling

unit:TimeUnit

the unit of measure of the delay amount

Returns:Disposable

the Disposable that let's one cancel this particular delayed task.

Annotations
@NonNull
@Override
io.reactivex.internal.schedulers back to summary

pack-priv final Class TrampolineScheduler.SleepingRunnable

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.schedulers.TrampolineScheduler.SleepingRunnable
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final long
private final Runnable
private final TrampolineScheduler.TrampolineWorker

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

execTimeback to summary
private final long execTime
runback to summary
private final Runnable run
workerback to summary
private final TrampolineScheduler.TrampolineWorker worker

Constructor Detail

SleepingRunnableback to summary
pack-priv SleepingRunnable(Runnable run, TrampolineScheduler.TrampolineWorker worker, long execTime)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
io.reactivex.internal.schedulers back to summary

pack-priv final Class TrampolineScheduler.TimedRunnable

extends Object
implements Comparable<TrampolineScheduler.TimedRunnable>
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.schedulers.TrampolineScheduler.TimedRunnable
All Implemented Interfaces
java.lang.Comparable

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv volatile boolean
pack-priv final long
pack-priv final Runnable

Constructor Summary

AccessConstructor and Description
pack-priv
TimedRunnable(Runnable run, Long execTime, int count)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(TrampolineScheduler.TimedRunnable
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

countback to summary
pack-priv final int count
disposedback to summary
pack-priv volatile boolean disposed
execTimeback to summary
pack-priv final long execTime
runback to summary
pack-priv final Runnable run

Constructor Detail

TimedRunnableback to summary
pack-priv TimedRunnable(Runnable run, Long execTime, int count)

Method Detail

compareToback to summary
public int compareTo(TrampolineScheduler.TimedRunnable 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.TimedRunnable

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

pack-priv final Class TrampolineScheduler.TrampolineWorker

extends Worker
implements Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicInteger
pack-priv volatile boolean
pack-priv final PriorityBlockingQueue<TrampolineScheduler.TimedRunnable>
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
pack-priv Disposable
enqueue(Runnable action, long execTime)

public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public Disposable
schedule(Runnable
Runnable to schedule
action
)

Overrides io.reactivex.Scheduler.Worker.schedule.

Schedules a Runnable for execution without any time delay.
public Disposable
schedule(Runnable
the Runnable 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 io.reactivex.Scheduler.Worker.schedule.

Schedules an Runnable for execution at some point in the future specified by a time delay relative to the current time.
Inherited from io.reactivex.Scheduler.Worker:
nowschedulePeriodically

Field Detail

counterback to summary
pack-priv final AtomicInteger counter
disposedback to summary
pack-priv volatile boolean disposed
queueback to summary
pack-priv final PriorityBlockingQueue<TrampolineScheduler.TimedRunnable> queue
wipback to summary
private final AtomicInteger wip

Constructor Detail

TrampolineWorkerback to summary
pack-priv TrampolineWorker()

Method Detail

disposeback to summary
public void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@Override
enqueueback to summary
pack-priv Disposable enqueue(Runnable action, long execTime)
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
scheduleback to summary
public Disposable schedule(Runnable action)

Overrides io.reactivex.Scheduler.Worker.schedule.

Doc from io.reactivex.Scheduler.Worker.schedule.

Schedules a Runnable for execution without any time delay.

The default implementation delegates to schedule(Runnable, long, TimeUnit).

Parameters
action:Runnable

Runnable to schedule

Returns:Disposable

a Disposable to be able to unsubscribe the action (cancel it if not executed)

Annotations
@NonNull
@Override
scheduleback to summary
public Disposable schedule(Runnable action, long delayTime, TimeUnit unit)

Implements abstract io.reactivex.Scheduler.Worker.schedule.

Doc from io.reactivex.Scheduler.Worker.schedule.

Schedules an Runnable for execution at some point in the future specified by a time delay relative to the current time.

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

Parameters
action:Runnable

the Runnable 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:Disposable

a Disposable to be able to unsubscribe the action (cancel it if not executed)

Annotations
@NonNull
@Override
io.reactivex.internal.schedulers back to summary

pack-priv final Class TrampolineScheduler.TrampolineWorker.AppendToQueueTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.schedulers.TrampolineScheduler.TrampolineWorker.AppendToQueueTask
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv final TrampolineScheduler.TimedRunnable

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

timedRunnableback to summary
pack-priv final TrampolineScheduler.TimedRunnable timedRunnable

Constructor Detail

AppendToQueueTaskback to summary
pack-priv AppendToQueueTask(TrampolineScheduler.TimedRunnable timedRunnable)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override