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

public final Class ExecutorScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.*, java.util.concurrent.atomic.*, io.reactivex.Scheduler, io.reactivex.annotations.NonNull, io.reactivex.disposables.*, io.reactivex.internal.disposables.*, io.reactivex.internal.functions.Functions, io.reactivex.internal.queue.MpscLinkedQueue, io.reactivex.internal.schedulers.ExecutorScheduler.ExecutorWorker.*, io.reactivex.plugins.RxJavaPlugins, io.reactivex.schedulers.*

Wraps an Executor and provides the Scheduler API over it.

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
pack-priv final Executor
pack-priv static final Scheduler
pack-priv final boolean

Constructor Summary

AccessConstructor and Description
public
ExecutorScheduler(Executor executor, boolean interruptibleWorker)

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 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
,
final long
the delay amount, non-positive values indicate non-delayed scheduling
delay
,
final 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.
public Disposable
schedulePeriodicallyDirect(Runnable
the task to schedule
run
,
long
the initial delay amount, non-positive values indicate non-delayed scheduling
initialDelay
,
long
the period at which the task should be re-executed
period
,
TimeUnit
the unit of measure of the delay amount
unit
)

Overrides io.reactivex.Scheduler.schedulePeriodicallyDirect.

Schedules a periodic execution of the given task with the given initial time delay and repeat period.
Inherited from io.reactivex.Scheduler:
clockDriftTolerancenowshutdownstartwhen

Field Detail

executorback to summary
pack-priv final Executor executor
Annotations
@NonNull
HELPERback to summary
pack-priv static final Scheduler HELPER
interruptibleWorkerback to summary
pack-priv final boolean interruptibleWorker

Constructor Detail

ExecutorSchedulerback to summary
public ExecutorScheduler(Executor executor, boolean interruptibleWorker)

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
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, final long delay, final 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
schedulePeriodicallyDirectback to summary
public Disposable schedulePeriodicallyDirect(Runnable run, long initialDelay, long period, TimeUnit unit)

Overrides io.reactivex.Scheduler.schedulePeriodicallyDirect.

Doc from io.reactivex.Scheduler.schedulePeriodicallyDirect.

Schedules a periodic execution of the given task with the given initial time delay and repeat period.

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

The periodic execution is at a fixed rate, that is, the first execution will be after the initialDelay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.

Parameters
run:Runnable

the task to schedule

initialDelay:long

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

period:long

the period at which the task should be re-executed

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 ExecutorScheduler.DelayedDispose

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

Field Summary

Modifier and TypeField and Description
private final ExecutorScheduler.DelayedRunnable

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

drback to summary
private final ExecutorScheduler.DelayedRunnable dr

Constructor Detail

DelayedDisposeback to summary
pack-priv DelayedDispose(ExecutorScheduler.DelayedRunnable dr)

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 ExecutorScheduler.DelayedRunnable

extends AtomicReference<Runnable>
implements Runnable, Disposable, SchedulerRunnableIntrospection
Class Inheritance
All Implemented Interfaces
io.reactivex.schedulers.SchedulerRunnableIntrospection, io.reactivex.disposables.Disposable, java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv final SequentialDisposable
private static final long
pack-priv final SequentialDisposable

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.
public Runnable
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.util.concurrent.atomic.AtomicReference:
accumulateAndGetcompareAndExchangecompareAndExchangeAcquirecompareAndExchangeReleasecompareAndSetgetgetAcquiregetAndAccumulategetAndSetgetAndUpdategetOpaquegetPlainlazySetsetsetOpaquesetPlainsetReleasetoStringupdateAndGetweakCompareAndSetweakCompareAndSetAcquireweakCompareAndSetPlainweakCompareAndSetReleaseweakCompareAndSetVolatile

Field Detail

directback to summary
pack-priv final SequentialDisposable direct
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicReference.serialVersionUID.

timedback to summary
pack-priv final SequentialDisposable timed

Constructor Detail

DelayedRunnableback to summary
pack-priv DelayedRunnable(Runnable run)

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
getWrappedRunnableback to summary
public Runnable getWrappedRunnable()

Implements io.reactivex.schedulers.SchedulerRunnableIntrospection.getWrappedRunnable.

Doc from io.reactivex.schedulers.SchedulerRunnableIntrospection.getWrappedRunnable.

Returns the wrapped action.

Returns:Runnable

the wrapped action. Cannot be null.

Annotations
@Override
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
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

public final Class ExecutorScheduler.ExecutorWorker

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
ExecutorScheduler.ExecutorWorker.InterruptibleRunnable

Wrapper for a Runnable with additional logic for handling interruption on a shared thread, similar to how Java Executors do it.

pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
pack-priv final Executor
pack-priv final boolean
pack-priv final MpscLinkedQueue<Runnable>
pack-priv final CompositeDisposable
pack-priv final AtomicInteger

Constructor Summary

AccessConstructor and Description
public
ExecutorWorker(Executor executor, boolean interruptibleWorker)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public Disposable
schedule(Runnable
Runnable to schedule
run
)

Overrides io.reactivex.Scheduler.Worker.schedule.

Schedules a Runnable for execution without any time delay.
public Disposable
schedule(Runnable
the Runnable to schedule
run
,
long
time to "wait" before executing the action; non-positive values indicate an non-delayed schedule
delay
,
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

disposedback to summary
pack-priv volatile boolean disposed
executorback to summary
pack-priv final Executor executor
interruptibleWorkerback to summary
pack-priv final boolean interruptibleWorker
queueback to summary
pack-priv final MpscLinkedQueue<Runnable> queue
tasksback to summary
pack-priv final CompositeDisposable tasks
wipback to summary
pack-priv final AtomicInteger wip

Constructor Detail

ExecutorWorkerback to summary
public ExecutorWorker(Executor executor, boolean interruptibleWorker)

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
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
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 Disposable schedule(Runnable run)

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
run: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 run, long delay, 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
run:Runnable

the Runnable to schedule

delay: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 ExecutorScheduler.ExecutorWorker.BooleanRunnable

extends AtomicBoolean
implements Runnable, Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable, java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv final Runnable
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

actualback to summary
pack-priv final Runnable actual
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicBoolean.serialVersionUID.

Constructor Detail

BooleanRunnableback to summary
pack-priv BooleanRunnable(Runnable actual)

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
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
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 ExecutorScheduler.ExecutorWorker.InterruptibleRunnable

extends AtomicInteger
implements Runnable, Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable, java.lang.Runnable

Wrapper for a Runnable with additional logic for handling interruption on a shared thread, similar to how Java Executors do it.

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv final Runnable
pack-priv static final int
private static final long
pack-priv final DisposableContainer
pack-priv volatile Thread

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

FINISHEDback to summary
pack-priv static final int FINISHED
INTERRUPTEDback to summary
pack-priv static final int INTERRUPTED
INTERRUPTINGback to summary
pack-priv static final int INTERRUPTING
READYback to summary
pack-priv static final int READY
runback to summary
pack-priv final Runnable run
RUNNINGback to summary
pack-priv static final int RUNNING
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.concurrent.atomic.AtomicInteger.serialVersionUID.

tasksback to summary
pack-priv final DisposableContainer tasks
threadback to summary
pack-priv volatile Thread thread

Constructor Detail

InterruptibleRunnableback to summary
pack-priv InterruptibleRunnable(Runnable run, DisposableContainer tasks)

Method Detail

cleanupback to summary
pack-priv void cleanup()
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
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
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 ExecutorScheduler.ExecutorWorker.SequentialDispose

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • io.reactivex.internal.schedulers.ExecutorScheduler.ExecutorWorker.SequentialDispose
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final Runnable
private final SequentialDisposable

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

decoratedRunback to summary
private final Runnable decoratedRun
marback to summary
private final SequentialDisposable mar

Constructor Detail

SequentialDisposeback to summary
pack-priv SequentialDispose(SequentialDisposable mar, Runnable decoratedRun)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override