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

public final Class IoScheduler

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

Scheduler that creates and caches a set of thread pools and reuses them if possible.

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
pack-priv static final RxThreadFactory
private static final String
private static final long
public static final long
private static final TimeUnit
private static final String
KEY_IO_PRIORITY

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

private static final String
KEY_KEEP_ALIVE_TIME

The name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.

private static final String
KEY_SCHEDULED_RELEASE

The name of the system property for setting the release behaviour for this Scheduler.

pack-priv static final IoScheduler.CachedWorkerPool
pack-priv final AtomicReference<IoScheduler.CachedWorkerPool>
pack-priv static final IoScheduler.ThreadWorker
pack-priv final ThreadFactory
pack-priv static boolean
pack-priv static final RxThreadFactory
private static final String

Constructor Summary

AccessConstructor and Description
public
public
IoScheduler(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 an IoScheduler with the given thread factory and starts the pool of workers.

Method Summary

Modifier and TypeMethod and Description
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 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 int
size()

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

EVICTOR_THREAD_FACTORYback to summary
pack-priv static final RxThreadFactory EVICTOR_THREAD_FACTORY
EVICTOR_THREAD_NAME_PREFIXback to summary
private static final String EVICTOR_THREAD_NAME_PREFIX
KEEP_ALIVE_TIMEback to summary
private static final long KEEP_ALIVE_TIME
KEEP_ALIVE_TIME_DEFAULTback to summary
public static final long KEEP_ALIVE_TIME_DEFAULT
KEEP_ALIVE_UNITback to summary
private static final TimeUnit KEEP_ALIVE_UNIT
KEY_IO_PRIORITYback to summary
private static final String KEY_IO_PRIORITY

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

KEY_KEEP_ALIVE_TIMEback to summary
private static final String KEY_KEEP_ALIVE_TIME

The name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.

KEY_SCHEDULED_RELEASEback to summary
private static final String KEY_SCHEDULED_RELEASE

The name of the system property for setting the release behaviour for this Scheduler.

NONEback to summary
pack-priv static final IoScheduler.CachedWorkerPool NONE
poolback to summary
pack-priv final AtomicReference<IoScheduler.CachedWorkerPool> pool
SHUTDOWN_THREAD_WORKERback to summary
pack-priv static final IoScheduler.ThreadWorker SHUTDOWN_THREAD_WORKER
threadFactoryback to summary
pack-priv final ThreadFactory threadFactory
USE_SCHEDULED_RELEASEback to summary
pack-priv static boolean USE_SCHEDULED_RELEASE
WORKER_THREAD_FACTORYback to summary
pack-priv static final RxThreadFactory WORKER_THREAD_FACTORY
WORKER_THREAD_NAME_PREFIXback to summary
private static final String WORKER_THREAD_NAME_PREFIX

Constructor Detail

IoSchedulerback to summary
public IoScheduler()
IoSchedulerback to summary
public IoScheduler(ThreadFactory threadFactory)

Constructs an IoScheduler with the given thread factory and starts the pool of workers.

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

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
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
sizeback to summary
public int size()
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 IoScheduler.CachedWorkerPool

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • io.reactivex.rxjava3.internal.schedulers.IoScheduler.CachedWorkerPool
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv final CompositeDisposable
private final ScheduledExecutorService
private final Future<?>
private final ConcurrentLinkedQueue<IoScheduler.ThreadWorker>
private final long
private final ThreadFactory

Constructor Summary

AccessConstructor and Description
pack-priv
CachedWorkerPool(long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory)

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
pack-priv IoScheduler.ThreadWorker
get()

pack-priv static long
now()

pack-priv void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allWorkersback to summary
pack-priv final CompositeDisposable allWorkers
evictorServiceback to summary
private final ScheduledExecutorService evictorService
evictorTaskback to summary
private final Future<?> evictorTask
expiringWorkerQueueback to summary
private final ConcurrentLinkedQueue<IoScheduler.ThreadWorker> expiringWorkerQueue
keepAliveTimeback to summary
private final long keepAliveTime
threadFactoryback to summary
private final ThreadFactory threadFactory

Constructor Detail

CachedWorkerPoolback to summary
pack-priv CachedWorkerPool(long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory)

Method Detail

evictExpiredWorkersback to summary
pack-priv static void evictExpiredWorkers(ConcurrentLinkedQueue<IoScheduler.ThreadWorker> expiringWorkerQueue, CompositeDisposable allWorkers)
getback to summary
pack-priv IoScheduler.ThreadWorker get()
nowback to summary
pack-priv static long now()
releaseback to summary
pack-priv void release(IoScheduler.ThreadWorker threadWorker)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
shutdownback to summary
pack-priv void shutdown()
io.reactivex.rxjava3.internal.schedulers back to summary

pack-priv final Class IoScheduler.EventLoopWorker

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

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicBoolean
private final IoScheduler.CachedWorkerPool
private final CompositeDisposable
private final IoScheduler.ThreadWorker

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 void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public @NonNull Disposable
schedule(@NonNull Runnable action, long delayTime, @NonNull TimeUnit unit)

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

Field Detail

onceback to summary
pack-priv final AtomicBoolean once
poolback to summary
private final IoScheduler.CachedWorkerPool pool
tasksback to summary
private final CompositeDisposable tasks
threadWorkerback to summary
private final IoScheduler.ThreadWorker threadWorker

Constructor Detail

EventLoopWorkerback to summary
pack-priv EventLoopWorker(IoScheduler.CachedWorkerPool pool)

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
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 @NonNull Disposable schedule(@NonNull Runnable action, long delayTime, @NonNull TimeUnit unit)
Annotations
@NonNull
@Override
io.reactivex.rxjava3.internal.schedulers back to summary

pack-priv final Class IoScheduler.ThreadWorker

extends NewThreadWorker
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv long
Inherited from io.reactivex.rxjava3.internal.schedulers.NewThreadWorker:
disposed

Constructor Summary

AccessConstructor and Description
pack-priv
ThreadWorker(ThreadFactory threadFactory)

Method Summary

Modifier and TypeMethod and Description
public long
public void
setExpirationTime(long expirationTime)

Inherited from io.reactivex.rxjava3.internal.schedulers.NewThreadWorker:
disposeisDisposedscheduleschedulescheduleActualscheduleDirectschedulePeriodicallyDirectshutdown

Field Detail

expirationTimeback to summary
pack-priv long expirationTime

Constructor Detail

ThreadWorkerback to summary
pack-priv ThreadWorker(ThreadFactory threadFactory)

Method Detail

getExpirationTimeback to summary
public long getExpirationTime()
setExpirationTimeback to summary
public void setExpirationTime(long expirationTime)