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

public final Class ImmediateThinScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.TimeUnit, io.reactivex.Scheduler, io.reactivex.annotations.NonNull, io.reactivex.disposables.*

A Scheduler partially implementing the API by allowing only non-delayed, non-periodic task execution on the current thread immediately.

Note that this doesn't support recursive scheduling and disposing the returned Disposable has no effect (because when the schedule() method returns, the task has been already run).

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final Disposable
public static final Scheduler
INSTANCE

The singleton instance of the immediate (thin) scheduler.

pack-priv static final Scheduler.Worker

Constructor Summary

AccessConstructor and Description
private

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
,
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.
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

DISPOSEDback to summary
pack-priv static final Disposable DISPOSED
INSTANCEback to summary
public static final Scheduler INSTANCE

The singleton instance of the immediate (thin) scheduler.

WORKERback to summary
pack-priv static final Scheduler.Worker WORKER

Constructor Detail

ImmediateThinSchedulerback to summary
private ImmediateThinScheduler()

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, 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
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 ImmediateThinScheduler.ImmediateThinWorker

extends Worker
Class Inheritance

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

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
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.
public Disposable
schedulePeriodically(Runnable
the Runnable to execute periodically
run
,
long
time to wait before executing the action for the first time; non-positive values indicate an non-delayed schedule
initialDelay
,
long
the time interval to wait each time in between executing the action; non-positive values indicate no delay between repeated schedules
period
,
TimeUnit
the time unit of period
unit
)

Overrides io.reactivex.Scheduler.Worker.schedulePeriodically.

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

Constructor Detail

ImmediateThinWorkerback to summary
pack-priv ImmediateThinWorker()

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
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
schedulePeriodicallyback to summary
public Disposable schedulePeriodically(Runnable run, long initialDelay, long period, TimeUnit unit)

Overrides io.reactivex.Scheduler.Worker.schedulePeriodically.

Doc from io.reactivex.Scheduler.Worker.schedulePeriodically.

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

The default implementation schedules and reschedules the Runnable task via the schedule(Runnable, long, TimeUnit) method over and over and 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.

Note to implementors: non-positive initialTime and period should be regarded as non-delayed scheduling of the first and any subsequent executions. In addition, a more specific Worker implementation should override this method if it can perform the periodic task execution with less overhead (such as by avoiding the creation of the wrapper and tracker objects upon each periodic invocation of the common schedule(Runnable, long, TimeUnit) method).

Parameters
run:Runnable

the Runnable to execute periodically

initialDelay:long

time to wait before executing the action for the first time; non-positive values indicate an non-delayed schedule

period:long

the time interval to wait each time in between executing the action; non-positive values indicate no delay between repeated schedules

unit:TimeUnit

the time unit of period

Returns:Disposable

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

Annotations
@NonNull
@Override