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

public final Class ComputationScheduler

extends Scheduler
implements SchedulerMultiWorkerSupport
Class Inheritance
All Implemented Interfaces
io.reactivex.rxjava3.internal.schedulers.SchedulerMultiWorkerSupport
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.*, io.reactivex.rxjava3.internal.functions.ObjectHelper

Holds a fixed pool of worker threads and assigns them to requested Scheduler.Workers in a round-robin fashion.

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
private static final String
KEY_COMPUTATION_PRIORITY

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

pack-priv static final String
KEY_MAX_THREADS

Key to setting the maximum number of computation scheduler threads.

pack-priv static final int
MAX_THREADS

The maximum number of computation scheduler threads.

pack-priv static final ComputationScheduler.FixedSchedulerPool
NONE

This will indicate no pool is active.

pack-priv final AtomicReference<ComputationScheduler.FixedSchedulerPool>
pack-priv static final ComputationScheduler.PoolWorker
pack-priv static final RxThreadFactory
private static final String
THREAD_NAME_PREFIX

Manages a fixed number of workers.

pack-priv final ThreadFactory

Constructor Summary

AccessConstructor and Description
public
ComputationScheduler()

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

public
ComputationScheduler(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
)

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

Method Summary

Modifier and TypeMethod and Description
pack-priv static int
cap(int cpuCount, int paramThreads)

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

KEY_COMPUTATION_PRIORITYback to summary
private static final String KEY_COMPUTATION_PRIORITY

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

KEY_MAX_THREADSback to summary
pack-priv static final String KEY_MAX_THREADS

Key to setting the maximum number of computation scheduler threads. Zero or less is interpreted as use available. Capped by available.

MAX_THREADSback to summary
pack-priv static final int MAX_THREADS

The maximum number of computation scheduler threads.

NONEback to summary
pack-priv static final ComputationScheduler.FixedSchedulerPool NONE

This will indicate no pool is active.

poolback to summary
pack-priv final AtomicReference<ComputationScheduler.FixedSchedulerPool> pool
SHUTDOWN_WORKERback to summary
pack-priv static final ComputationScheduler.PoolWorker SHUTDOWN_WORKER
THREAD_FACTORYback to summary
pack-priv static final RxThreadFactory THREAD_FACTORY
THREAD_NAME_PREFIXback to summary
private static final String THREAD_NAME_PREFIX

Manages a fixed number of workers.

threadFactoryback to summary
pack-priv final ThreadFactory threadFactory

Constructor Detail

ComputationSchedulerback to summary
public ComputationScheduler()

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

ComputationSchedulerback to summary
public ComputationScheduler(ThreadFactory threadFactory)

Create a scheduler with pool size equal to the available processor count and using least-recent worker selection policy.

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

capback to summary
pack-priv static int cap(int cpuCount, int paramThreads)
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
createWorkersback to summary
public void createWorkers(int number, SchedulerMultiWorkerSupport.WorkerCallback callback)
Annotations
@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 ComputationScheduler.EventLoopWorker

extends Worker
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ListCompositeDisposable
pack-priv volatile boolean
private final ComputationScheduler.PoolWorker
private final ListCompositeDisposable
private 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
public @NonNull Disposable
schedule(@NonNull Runnable action, long delayTime, @NonNull TimeUnit unit)

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

Field Detail

bothback to summary
private final ListCompositeDisposable both
disposedback to summary
pack-priv volatile boolean disposed
poolWorkerback to summary
private final ComputationScheduler.PoolWorker poolWorker
serialback to summary
private final ListCompositeDisposable serial
timedback to summary
private final CompositeDisposable timed

Constructor Detail

EventLoopWorkerback to summary
pack-priv EventLoopWorker(ComputationScheduler.PoolWorker poolWorker)

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 action)
Annotations
@NonNull
@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 ComputationScheduler.FixedSchedulerPool

extends Object
implements SchedulerMultiWorkerSupport
Class Inheritance
  • java.lang.Object
  • io.reactivex.rxjava3.internal.schedulers.ComputationScheduler.FixedSchedulerPool
All Implemented Interfaces
io.reactivex.rxjava3.internal.schedulers.SchedulerMultiWorkerSupport

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final ComputationScheduler.PoolWorker[]
pack-priv long
n

Constructor Summary

AccessConstructor and Description
pack-priv
FixedSchedulerPool(int maxThreads, ThreadFactory threadFactory)

Method Summary

Modifier and TypeMethod and Description
public void
public ComputationScheduler.PoolWorker
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

coresback to summary
pack-priv final int cores
eventLoopsback to summary
pack-priv final ComputationScheduler.PoolWorker[] eventLoops
nback to summary
pack-priv long n

Constructor Detail

FixedSchedulerPoolback to summary
pack-priv FixedSchedulerPool(int maxThreads, ThreadFactory threadFactory)

Method Detail

createWorkersback to summary
public void createWorkers(int number, SchedulerMultiWorkerSupport.WorkerCallback callback)
Annotations
@Override
getEventLoopback to summary
public ComputationScheduler.PoolWorker getEventLoop()
shutdownback to summary
public void shutdown()
io.reactivex.rxjava3.internal.schedulers back to summary

pack-priv final Class ComputationScheduler.PoolWorker

extends NewThreadWorker
Class Inheritance

Field Summary

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

Constructor Summary

AccessConstructor and Description
pack-priv
PoolWorker(ThreadFactory threadFactory)

Method Summary

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

Constructor Detail

PoolWorkerback to summary
pack-priv PoolWorker(ThreadFactory threadFactory)