Class IoScheduler
- java.lang.Object
-
- io.reactivex.rxjava3.core.Scheduler
-
- io.reactivex.rxjava3.internal.schedulers.IoScheduler
-
public final class IoScheduler extends Scheduler
Scheduler that creates and caches a set of thread pools and reuses them if possible.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classIoScheduler.CachedWorkerPool(package private) static classIoScheduler.EventLoopWorker(package private) static classIoScheduler.ThreadWorker-
Nested classes/interfaces inherited from class io.reactivex.rxjava3.core.Scheduler
Scheduler.Worker
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static RxThreadFactoryEVICTOR_THREAD_FACTORYprivate static java.lang.StringEVICTOR_THREAD_NAME_PREFIXprivate static longKEEP_ALIVE_TIMEstatic longKEEP_ALIVE_TIME_DEFAULTprivate static java.util.concurrent.TimeUnitKEEP_ALIVE_UNITprivate static java.lang.StringKEY_IO_PRIORITYThe name of the system property for setting the thread priority for this Scheduler.private static java.lang.StringKEY_KEEP_ALIVE_TIMEThe name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.private static java.lang.StringKEY_SCHEDULED_RELEASEThe name of the system property for setting the release behaviour for this Scheduler.(package private) static IoScheduler.CachedWorkerPoolNONE(package private) java.util.concurrent.atomic.AtomicReference<IoScheduler.CachedWorkerPool>pool(package private) static IoScheduler.ThreadWorkerSHUTDOWN_THREAD_WORKER(package private) java.util.concurrent.ThreadFactorythreadFactory(package private) static booleanUSE_SCHEDULED_RELEASE(package private) static RxThreadFactoryWORKER_THREAD_FACTORYprivate static java.lang.StringWORKER_THREAD_NAME_PREFIX
-
Constructor Summary
Constructors Constructor Description IoScheduler()IoScheduler(java.util.concurrent.ThreadFactory threadFactory)Constructs an IoScheduler with the given thread factory and starts the pool of workers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull Scheduler.WorkercreateWorker()Retrieves 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 io.reactivex.rxjava3.core.Scheduler
clockDriftTolerance, now, scheduleDirect, scheduleDirect, schedulePeriodicallyDirect, when
-
-
-
-
Field Detail
-
WORKER_THREAD_NAME_PREFIX
private static final java.lang.String WORKER_THREAD_NAME_PREFIX
- See Also:
- Constant Field Values
-
WORKER_THREAD_FACTORY
static final RxThreadFactory WORKER_THREAD_FACTORY
-
EVICTOR_THREAD_NAME_PREFIX
private static final java.lang.String EVICTOR_THREAD_NAME_PREFIX
- See Also:
- Constant Field Values
-
EVICTOR_THREAD_FACTORY
static final RxThreadFactory EVICTOR_THREAD_FACTORY
-
KEY_KEEP_ALIVE_TIME
private static final java.lang.String KEY_KEEP_ALIVE_TIME
The name of the system property for setting the keep-alive time (in seconds) for this Scheduler workers.- See Also:
- Constant Field Values
-
KEEP_ALIVE_TIME_DEFAULT
public static final long KEEP_ALIVE_TIME_DEFAULT
- See Also:
- Constant Field Values
-
KEEP_ALIVE_TIME
private static final long KEEP_ALIVE_TIME
-
KEEP_ALIVE_UNIT
private static final java.util.concurrent.TimeUnit KEEP_ALIVE_UNIT
-
SHUTDOWN_THREAD_WORKER
static final IoScheduler.ThreadWorker SHUTDOWN_THREAD_WORKER
-
threadFactory
final java.util.concurrent.ThreadFactory threadFactory
-
pool
final java.util.concurrent.atomic.AtomicReference<IoScheduler.CachedWorkerPool> pool
-
KEY_IO_PRIORITY
private static final java.lang.String KEY_IO_PRIORITY
The name of the system property for setting the thread priority for this Scheduler.- See Also:
- Constant Field Values
-
KEY_SCHEDULED_RELEASE
private static final java.lang.String KEY_SCHEDULED_RELEASE
The name of the system property for setting the release behaviour for this Scheduler.- See Also:
- Constant Field Values
-
USE_SCHEDULED_RELEASE
static boolean USE_SCHEDULED_RELEASE
-
NONE
static final IoScheduler.CachedWorkerPool NONE
-
-
Constructor Detail
-
IoScheduler
public IoScheduler()
-
IoScheduler
public IoScheduler(java.util.concurrent.ThreadFactory threadFactory)
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 Detail
-
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
@NonNull public @NonNull Scheduler.Worker 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()
-
-