public static abstract class

Scheduler.Worker

extends Object
implements Disposable
java.lang.Object
   ↳ io.reactivex.Scheduler.Worker

Class Overview

Sequential Scheduler for executing actions on a single thread or event loop.

Disposing the Scheduler.Worker cancels all outstanding work and allows resource cleanup.

Summary

Public Constructors
Worker()
Public Methods
long now(TimeUnit unit)
Returns the 'current time' of the Worker in the specified time unit.
Disposable schedule(Runnable run)
Schedules a Runnable for execution without delay.
abstract Disposable schedule(Runnable run, long delay, TimeUnit unit)
Schedules an Runnable for execution at some point in the future.
Disposable schedulePeriodically(Runnable run, long initialDelay, long period, TimeUnit unit)
Schedules a cancelable action to be executed periodically.
[Expand]
Inherited Methods
From class java.lang.Object
From interface io.reactivex.disposables.Disposable

Public Constructors

public Worker ()

Public Methods

public long now (TimeUnit unit)

Returns the 'current time' of the Worker in the specified time unit.

Parameters
unit the time unit
Returns
  • the 'current time'

public Disposable schedule (Runnable run)

Schedules a Runnable for execution without delay.

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

Parameters
run Runnable to schedule
Returns
  • a Disposable to be able to unsubscribe the action (cancel it if not executed)

public abstract Disposable schedule (Runnable run, long delay, TimeUnit unit)

Schedules an Runnable 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(Runnable) was called.

Parameters
run the Runnable to schedule
delay time to wait before executing the action; non-positive values indicate an non-delayed schedule
unit the time unit of delayTime
Returns
  • a Disposable to be able to unsubscribe the action (cancel it if not executed)

public Disposable schedulePeriodically (Runnable run, long initialDelay, long period, TimeUnit unit)

Schedules a cancelable action to be executed periodically. This default implementation schedules recursively and waits for actions to complete (instead of potentially executing long-running actions concurrently). Each scheduler that can do periodic scheduling in a better way should override this.

Note to implementors: non-positive initialTime and period should be regarded as non-delayed scheduling of the first and any subsequent executions.

Parameters
run the Runnable to execute periodically
initialDelay time to wait before executing the action for the first time; non-positive values indicate an non-delayed schedule
period the time interval to wait each time in between executing the action; non-positive values indicate no delay between repeated schedules
unit the time unit of period
Returns
  • a Disposable to be able to unsubscribe the action (cancel it if not executed)