Class IoScheduler
java.lang.Object
io.reactivex.rxjava3.core.Scheduler
io.reactivex.rxjava3.internal.schedulers.IoScheduler
Scheduler that creates and caches a set of thread pools and reuses them if possible.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class(package private) static final class(package private) static final classNested classes/interfaces inherited from class Scheduler
Scheduler.Worker -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final RxThreadFactoryprivate static final Stringprivate static final longstatic final longprivate static final TimeUnitprivate static final StringThe name of the system property for setting the thread priority for this Scheduler.private static final StringThe name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.private static final StringThe name of the system property for setting the release behaviour for this Scheduler.(package private) static final IoScheduler.CachedWorkerPool(package private) final AtomicReference<IoScheduler.CachedWorkerPool> (package private) static final IoScheduler.ThreadWorker(package private) final ThreadFactory(package private) static boolean(package private) static final RxThreadFactoryprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionIoScheduler(ThreadFactory threadFactory) Constructs an IoScheduler with the given thread factory and starts the pool of workers. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves or creates a newScheduler.Workerthat represents sequential execution of actions.voidshutdown()Instructs the Scheduler instance to stop threads, stop accepting tasks on any outstandingScheduler.Workerinstances and clean up any associated resources with this Scheduler.intsize()voidstart()Allows the Scheduler instance to start threads and accept tasks on them.Methods inherited from class Scheduler
clockDriftTolerance, now, scheduleDirect, scheduleDirect, schedulePeriodicallyDirect, when
-
Field Details
-
WORKER_THREAD_NAME_PREFIX
- See Also:
-
WORKER_THREAD_FACTORY
-
EVICTOR_THREAD_NAME_PREFIX
- See Also:
-
EVICTOR_THREAD_FACTORY
-
KEY_KEEP_ALIVE_TIME
The name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.- See Also:
-
KEEP_ALIVE_TIME_DEFAULT
public static final long KEEP_ALIVE_TIME_DEFAULT- See Also:
-
KEEP_ALIVE_TIME
private static final long KEEP_ALIVE_TIME -
KEEP_ALIVE_UNIT
-
SHUTDOWN_THREAD_WORKER
-
threadFactory
-
pool
-
KEY_IO_PRIORITY
The name of the system property for setting the thread priority for this Scheduler.- See Also:
-
KEY_SCHEDULED_RELEASE
The name of the system property for setting the release behaviour for this Scheduler.- See Also:
-
USE_SCHEDULED_RELEASE
static boolean USE_SCHEDULED_RELEASE -
NONE
-
-
Constructor Details
-
IoScheduler
public IoScheduler() -
IoScheduler
Constructs an IoScheduler with the given thread factory and starts the pool of workers.- Parameters:
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 Details
-
start
public void start()Description copied from class:SchedulerAllows 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
RuntimeExceptionif it doesn't support this functionality. -
shutdown
public void shutdown()Description copied from class:SchedulerInstructs the Scheduler instance to stop threads, stop accepting tasks on any outstandingScheduler.Workerinstances and clean up any associated resources with this Scheduler.Implementations should make sure the call is idempotent, thread-safe and should not throw any
RuntimeExceptionif it doesn't support this functionality. -
createWorker
Description copied from class:SchedulerRetrieves or creates a newScheduler.Workerthat represents sequential execution of actions.When work is completed, the
Workerinstance should be released by callingDisposable.dispose()to avoid potential resource leaks in the underlying task-execution scheme.Work on a
Scheduler.Workeris guaranteed to be sequential and non-overlapping.- Specified by:
createWorkerin classScheduler- Returns:
- a Worker representing a serial queue of actions to be executed
-
size
public int size()
-