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

public final Class SingleScheduler

extends Scheduler
Class Inheritance
Imports
java.util.concurrent.*, java.util.concurrent.atomic.AtomicReference, io.reactivex.rxjava3.annotations.NonNull, io.reactivex.rxjava3.core.Scheduler, io.reactivex.rxjava3.disposables.*, io.reactivex.rxjava3.internal.disposables.EmptyDisposable, io.reactivex.rxjava3.plugins.RxJavaPlugins

A scheduler with a shared, single threaded underlying ScheduledExecutorService.
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<ScheduledExecutorService>
private static final String
KEY_SINGLE_PRIORITY

The name of the system property for setting the thread priority for this Scheduler.

pack-priv static final ScheduledExecutorService
pack-priv static final RxThreadFactory
private static final String
pack-priv final ThreadFactory

Constructor Summary

AccessConstructor and Description
public
public
SingleScheduler(ThreadFactory
thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.
threadFactory
)

Constructs a SingleScheduler with the given ThreadFactory and prepares the single scheduler thread.

Method Summary

Modifier and TypeMethod and Description
pack-priv static ScheduledExecutorService
public @NonNull Scheduler.Worker
createWorker()

Implements abstract io.reactivex.rxjava3.core.Scheduler.createWorker.

Retrieves or creates a new Scheduler.Worker that represents sequential execution of actions.
public @NonNull Disposable
scheduleDirect(@NonNull Runnable run, long delay, TimeUnit unit)

public @NonNull Disposable
schedulePeriodicallyDirect(@NonNull Runnable run, long initialDelay, long period, TimeUnit unit)

public void
shutdown()

Overrides io.reactivex.rxjava3.core.Scheduler.shutdown.

Instructs the Scheduler instance to stop threads, stop accepting tasks on any outstanding Worker instances and clean up any associated resources with this Scheduler.
public void
start()

Overrides io.reactivex.rxjava3.core.Scheduler.start.

Allows the Scheduler instance to start threads and accept tasks on them.
Inherited from io.reactivex.rxjava3.core.Scheduler:
clockDriftTolerancenowscheduleDirectscheduleDirectschedulePeriodicallyDirectwhen

Field Detail

executorback to summary
pack-priv final AtomicReference<ScheduledExecutorService> executor
KEY_SINGLE_PRIORITYback to summary
private static final String KEY_SINGLE_PRIORITY

The name of the system property for setting the thread priority for this Scheduler.

SHUTDOWNback to summary
pack-priv static final ScheduledExecutorService SHUTDOWN
SINGLE_THREAD_FACTORYback to summary
pack-priv static final RxThreadFactory SINGLE_THREAD_FACTORY
THREAD_NAME_PREFIXback to summary
private static final String THREAD_NAME_PREFIX
threadFactoryback to summary
pack-priv final ThreadFactory threadFactory

Constructor Detail

SingleSchedulerback to summary
public SingleScheduler()
SingleSchedulerback to summary
public SingleScheduler(ThreadFactory threadFactory)

Constructs a SingleScheduler with the given ThreadFactory and prepares the single scheduler thread.

Parameters
threadFactory:ThreadFactory

thread factory to use for creating worker threads. Note that this takes precedence over any system properties for configuring new thread creation. Cannot be null.

Method Detail

createExecutorback to summary
pack-priv static ScheduledExecutorService createExecutor(ThreadFactory threadFactory)
createWorkerback to summary
public @NonNull Scheduler.Worker createWorker()

Implements abstract io.reactivex.rxjava3.core.Scheduler.createWorker.

Doc from io.reactivex.rxjava3.core.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:@NonNull Scheduler.Worker

a Worker representing a serial queue of actions to be executed

Annotations
@NonNull
@Override
scheduleDirectback to summary
public @NonNull Disposable scheduleDirect(@NonNull Runnable run, long delay, TimeUnit unit)
Annotations
@NonNull
@Override
schedulePeriodicallyDirectback to summary
public @NonNull Disposable schedulePeriodicallyDirect(@NonNull Runnable run, long initialDelay, long period, TimeUnit unit)
Annotations
@NonNull
@Override
shutdownback to summary
public void shutdown()

Overrides io.reactivex.rxjava3.core.Scheduler.shutdown.

Doc from io.reactivex.rxjava3.core.Scheduler.shutdown.

Instructs the Scheduler instance to stop threads, stop accepting tasks on any outstanding Worker instances and clean up any associated resources with this Scheduler.

Implementations should make sure the call is idempotent, thread-safe and should not throw any RuntimeException if it doesn't support this functionality.

Annotations
@Override
startback to summary
public void start()

Overrides io.reactivex.rxjava3.core.Scheduler.start.

Doc from io.reactivex.rxjava3.core.Scheduler.start.

Allows the Scheduler instance to start threads and accept tasks on them.

Implementations should make sure the call is idempotent, thread-safe and should not throw any RuntimeException if it doesn't support this functionality.

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

pack-priv final Class SingleScheduler.ScheduledWorker

extends Worker
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements io.reactivex.rxjava3.disposables.Disposable.dispose.

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

Implements io.reactivex.rxjava3.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
public @NonNull Disposable
schedule(@NonNull Runnable run, long delay, @NonNull TimeUnit unit)

Inherited from io.reactivex.rxjava3.core.Scheduler.Worker:
nowschedulescheduleschedulePeriodically

Field Detail

disposedback to summary
pack-priv volatile boolean disposed
executorback to summary
pack-priv final ScheduledExecutorService executor
tasksback to summary
pack-priv final CompositeDisposable tasks

Constructor Detail

ScheduledWorkerback to summary
pack-priv ScheduledWorker(ScheduledExecutorService executor)

Method Detail

disposeback to summary
public void dispose()

Implements io.reactivex.rxjava3.disposables.Disposable.dispose.

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

Dispose the resource, the operation should be idempotent.

Annotations
@Override
isDisposedback to summary
public boolean isDisposed()

Implements io.reactivex.rxjava3.disposables.Disposable.isDisposed.

Doc from io.reactivex.rxjava3.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 @NonNull Disposable schedule(@NonNull Runnable run, long delay, @NonNull TimeUnit unit)
Annotations
@NonNull
@Override