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

public Class NewThreadWorker

extends Worker
implements Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable
Known Direct Subclasses
io.reactivex.internal.schedulers.ComputationScheduler.PoolWorker, io.reactivex.internal.schedulers.IoScheduler.ThreadWorker
Imports
java.util.concurrent.*, io.reactivex.Scheduler, io.reactivex.annotations.NonNull, .Nullable, io.reactivex.disposables.*, io.reactivex.internal.disposables.*, io.reactivex.plugins.RxJavaPlugins

Base class that manages a single-threaded ScheduledExecutorService as a worker but doesn't perform task-tracking operations.

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
private final ScheduledExecutorService

Constructor Summary

AccessConstructor and Description
public

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

Overrides io.reactivex.Scheduler.Worker.schedule.

Schedules a Runnable for execution without any time delay.
public Disposable
schedule(final 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.
public ScheduledRunnable

Returns:

the ScheduledRunnable instance
scheduleActual
(final Runnable
the runnable instance
run
,
long
the time to delay the execution
delayTime
,
TimeUnit
the time unit
unit
,
DisposableContainer
the optional tracker parent to add the created ScheduledRunnable instance to before it gets scheduled
parent
)

Wraps the given runnable into a ScheduledRunnable and schedules it on the underlying ScheduledExecutorService.

public Disposable

Returns:

the ScheduledRunnable instance
scheduleDirect
(final Runnable
the Runnable to execute in a delayed fashion
run
,
long
the delay amount
delayTime
,
TimeUnit
the delay time unit
unit
)

Schedules the given runnable on the underlying executor directly and returns its future wrapped into a Disposable.

public Disposable

Returns:

the ScheduledRunnable instance
schedulePeriodicallyDirect
(Runnable
the Runnable to execute in a periodic fashion
run
,
long
the initial delay amount
initialDelay
,
long
the repeat period amount
period
,
TimeUnit
the time unit for both the initialDelay and period
unit
)

Schedules the given runnable periodically on the underlying executor directly and returns its future wrapped into a Disposable.

public void
shutdown()

Shuts down the underlying executor in a non-interrupting fashion.

Inherited from io.reactivex.Scheduler.Worker:
nowschedulePeriodically

Field Detail

disposedback to summary
pack-priv volatile boolean disposed
executorback to summary
private final ScheduledExecutorService executor

Constructor Detail

NewThreadWorkerback to summary
public NewThreadWorker(ThreadFactory threadFactory)

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(final 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(final 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
scheduleActualback to summary
public ScheduledRunnable scheduleActual(final Runnable run, long delayTime, TimeUnit unit, DisposableContainer parent)

Wraps the given runnable into a ScheduledRunnable and schedules it on the underlying ScheduledExecutorService.

If the schedule has been rejected, the ScheduledRunnable.wasScheduled will return false.

Parameters
run:Runnable

the runnable instance

delayTime:long

the time to delay the execution

unit:TimeUnit

the time unit

parent:DisposableContainer

the optional tracker parent to add the created ScheduledRunnable instance to before it gets scheduled

Returns:ScheduledRunnable

the ScheduledRunnable instance

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

Schedules the given runnable on the underlying executor directly and returns its future wrapped into a Disposable.

Parameters
run:Runnable

the Runnable to execute in a delayed fashion

delayTime:long

the delay amount

unit:TimeUnit

the delay time unit

Returns:Disposable

the ScheduledRunnable instance

schedulePeriodicallyDirectback to summary
public Disposable schedulePeriodicallyDirect(Runnable run, long initialDelay, long period, TimeUnit unit)

Schedules the given runnable periodically on the underlying executor directly and returns its future wrapped into a Disposable.

Parameters
run:Runnable

the Runnable to execute in a periodic fashion

initialDelay:long

the initial delay amount

period:long

the repeat period amount

unit:TimeUnit

the time unit for both the initialDelay and period

Returns:Disposable

the ScheduledRunnable instance

shutdownback to summary
public void shutdown()

Shuts down the underlying executor in a non-interrupting fashion.