Schedulers provides various Scheduler flavors usable by publishOn or subscribeOn :
parallel(): Optimized for fast Runnable non-blocking executions single: Optimized for low-latency Runnable one-off executions boundedElastic(): Optimized for longer executions, an alternative for blocking tasks where the number of active tasks (and threads) is cappedimmediate: to immediately run submitted Runnable instead of scheduling them (somewhat of a no-op or "null object" Scheduler)fromExecutorService(ExecutorService) to create new instances around java.util.concurrent.Executors
Factories prefixed with new (eg. newBoundedElastic(int, int, String) return a new instance of their flavor of Scheduler,
while other factories like boundedElastic() return a shared instance - which is the one used by operators requiring that flavor as their default Scheduler.
All instances are returned in a initialized state.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| public static interface | Schedulers.Factory
Public factory hook to override Schedulers behavior globally |
| public static class | Schedulers.Snapshot
It is also |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final String | |
| pack-priv static final Supplier | |
| pack-priv static AtomicReference | |
| pack-priv static AtomicReference | |
| pack-priv static AtomicReference | |
| pack-priv static final Map | |
| pack-priv static final Schedulers. | |
| public static final boolean | DEFAULT_BOUNDED_ELASTIC_ON_VIRTUAL_THREADS
Default execution of enqueued tasks on |
| public static final int | DEFAULT_BOUNDED_ELASTIC_QUEUESIZE
Default maximum number of enqueued tasks PER THREAD for the global |
| public static final int | DEFAULT_BOUNDED_ELASTIC_SIZE
Default maximum size for the global |
| public static final int | DEFAULT_POOL_SIZE
Default pool size, initialized by system property |
| pack-priv static volatile Schedulers. | |
| pack-priv static final String | |
| pack-priv static final String | |
| pack-priv static final String | |
| pack-priv static final Logger | |
| pack-priv static final String | |
| pack-priv static BiConsumer | |
| private static final LinkedHashMap | |
| private static Function | |
| private static final LinkedHashMap | |
| pack-priv static final String | |
| pack-priv static final Supplier | |
| pack-priv static final String | |
| pack-priv static final Supplier |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static boolean | Returns: true if the decorator was added, false if a decorator was already present for this key.the key under which to set up the decorator key, BiFunction<Scheduler, ScheduledExecutorService, ScheduledExecutorService> the executor service decorator to add, if key not already present. decorator)Set up an additional |
| public static Scheduler | Returns: the common boundedElastic instance, aScheduler that dynamically creates workers with
an upper bound to the number of backing threads and after that on the number of enqueued tasks, that reuses
threads and evict idle onesThe common boundedElastic instance, a |
| pack-priv static Schedulers. | Returns: aCachedScheduler to be reused, either pre-existing or createdthe cache reference that holds the scheduler reference,the "name" for the Scheduler's category/type key, Supplier<Scheduler> the supplier)Scheduler generator to use and wrap into a CachedScheduler.
Note that in case of a race, an extraneous Scheduler can be created, but it'll get
immediately disposed.Get a |
| private static BiConsumer | |
| public static ScheduledExecutorService | Returns: the decoratedScheduledExecutorService, or the original if no decorator is set upa owner, ScheduledExecutorService Scheduler that owns the ScheduledExecutorServicethe original)ScheduledExecutorService that the Scheduler
wants to use originallyThis method is aimed at |
| pack-priv static final void | |
| pack-priv static Disposable | directSchedule(ScheduledExecutorService exec, Runnable task, Disposable parent, long delay, TimeUnit unit)
|
| pack-priv static Disposable | directSchedulePeriodically(ScheduledExecutorService exec, Runnable task, long initialDelay, long period, TimeUnit unit)
|
| public static void | disableMetrics()
Deprecated
prefer using Micrometer#timedScheduler from the reactor-core-micrometer module. To be removed at the earliest in 3.6.0.
If enableMetrics() has been previously called, removes the decorator.
|
| public static void | enableMetrics()
Deprecated
prefer using Micrometer#timedScheduler from the reactor-core-micrometer module. To be removed at the earliest in 3.6.0.
If Micrometer is available, set-up a decorator that will instrument any
ExecutorService that backs a Scheduler.
|
| public static Scheduler | |
| public static Scheduler | |
| public static Scheduler | Returns: a newSchedulerCreate a |
| public static Scheduler | Returns: a newSchedulerCreate a |
| pack-priv static void | |
| public static Scheduler | |
| public static boolean | Returns: true if blocking is forbidden in this thread, false otherwiseCheck if calling a Reactor blocking API in the current |
| public static boolean | Returns: true if blocking is forbidden in that thread, false otherwiseCheck if calling a Reactor blocking API in the given |
| public static Scheduler | Returns: a newScheduler that dynamically creates workers with an upper bound to
the number of backing threads and after that on the number of enqueued tasks,
that reuses threads and evict idle onesmaximum number of underlying threads to create threadCap, int maximum number of tasks to enqueue when no more threads can be created. Can be queuedTaskCap, String Integer#MAX_VALUE for unbounded enqueueing.Thread prefix name)
|
| public static Scheduler | Returns: a newScheduler that dynamically creates workers with an upper bound to
the number of backing threads and after that on the number of enqueued tasks,
that reuses threads and evict idle onesmaximum number of underlying threads to create threadCap, int maximum number of tasks to enqueue when no more threads can be created. Can be queuedTaskCap, String Integer#MAX_VALUE for unbounded enqueueing.Thread prefix name, int Time-to-live for an idle ttlSeconds)reactor.
|
| public static Scheduler | Returns: a newScheduler that dynamically creates workers with an upper bound to
the number of backing threads and after that on the number of enqueued tasks,
that reuses threads and evict idle onesmaximum number of underlying threads to create threadCap, int maximum number of tasks to enqueue when no more threads can be created. Can be queuedTaskCap, String Integer#MAX_VALUE for unbounded enqueueing.Thread prefix name, int Time-to-live for an idle ttlSeconds, boolean reactor.are backing threads daemon)daemon threads
|
| public static Scheduler | Returns: a newScheduler that dynamically creates workers with an upper bound to
the number of backing threads and after that on the number of enqueued tasks,
that reuses threads and evict idle onesmaximum number of underlying threads to create threadCap, int maximum number of tasks to enqueue when no more threads can be created. Can be queuedTaskCap, ThreadFactory Integer#MAX_VALUE for unbounded enqueueing.a threadFactory, int ThreadFactory to use each thread initializationTime-to-live for an idle ttlSeconds)reactor.
|
| public static Scheduler | Returns: a newScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workThread prefix name)
|
| public static Scheduler | Returns: a newScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workThread prefix name, int Number of pooled workers. parallelism)
|
| public static Scheduler | Returns: a newScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workThread prefix name, int Number of pooled workers. parallelism, boolean false if the daemon)Scheduler requires an explicit Scheduler#dispose() to exit the VM.
|
| public static Scheduler | Returns: a newScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workNumber of pooled workers. parallelism, ThreadFactory a threadFactory)ThreadFactory to use for the fixed initialized
number of Thread
|
| public static Scheduler | |
| public static Scheduler | |
| public static Scheduler | Returns: a newScheduler that hosts a single-threaded ExecutorService-based
workera threadFactory)ThreadFactory to use for the unique thread of the
Scheduler
|
| pack-priv static Scheduler | |
| public static void | onHandleError(BiConsumer<Thread, ? super Throwable>
the new subHook)BiConsumer to set as the hook's anonymous part.Define a hook anonymous part that is executed alongside keyed parts when a |
| public static void | onHandleError(String
the key, BiConsumer<Thread, ? super Throwable> String key identifying the hook part to set/replace.the new hook part to set for the given key. subHook)Define a keyed hook part that is executed alongside other parts when a |
| public static Runnable | Returns: decoratedRunnable if any hook is registered, the original otherwise.Applies the hooks registered with |
| public static void | |
| public static Scheduler | Returns: the common parallel instance, aScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workThe common parallel instance, a |
| public static BiFunction | Returns: the removed decorator, or null if none was set for that keythe key for the executor service decorator to remove key)Remove an existing |
| public static void | |
| public static void | resetFrom(Schedulers.
Replace the current Factory and shared Schedulers with the ones saved in a
previously |
| public static void | resetOnHandleError()
Reset the |
| public static void | resetOnHandleError(String key)
Reset a specific onHandleError hook part keyed to the provided |
| public static void | resetOnScheduleHook(String
the key for onScheduleHook sub-hook to remove key)Reset a specific onScheduleHook |
| public static void | |
| pack-priv static final Object | Returns: an equivalent ofScannable#scanUnsafe(Scannable. but that can
also work on some implementations of Executorthe executor to introspect in a best effort manner. executor, Scannable.the key to scan for. CAPACITY and BUFFERED mainly. keyScan an |
| public static void | setExecutorServiceDecorator(String
the key under which to set up the decorator key, BiFunction<Scheduler, ScheduledExecutorService, ScheduledExecutorService> the executor service decorator to add, if key not already present. decorator)Set up an additional |
| public static void | setFactory(Schedulers.
an arbitrary factoryInstanceFactory instance.Replace |
| public static Schedulers. | setFactoryWithSnapshot(Schedulers.
an arbitrary newFactoryFactory instanceReplace |
| public static void | |
| public static Scheduler | |
| public static Scheduler | single(Scheduler
a original)Scheduler to call upon to get the single reactor.Wraps a single |
| pack-priv static Disposable | workerSchedule(ScheduledExecutorService exec, Disposable.
|
| pack-priv static Disposable | workerSchedulePeriodically(ScheduledExecutorService exec, Disposable.
|