public final class ForkJoinPoolScheduler extends Object implements Scheduler
Disposable.Composite, Disposable.Swap| Modifier and Type | Method and Description |
|---|---|
static Scheduler |
create(int parallelism,
ForkJoinPool.ForkJoinWorkerThreadFactory workerThreadFactory,
Scheduler timeScheduler)
Scheduler that utilizes a ForkJoinPool for
workers and is suited for parallel work. |
static Scheduler |
create(String name)
Scheduler that hosts a fixed pool of single-threaded ExecutorService-based
workers and is suited for parallel work. |
static Scheduler |
create(String name,
int parallelism)
Scheduler that utilizes a ForkJoinPool for
workers and is suited for parallel work. |
Scheduler.Worker |
createWorker() |
void |
dispose() |
boolean |
isDisposed() |
static void |
onHandleError(java.util.function.BiConsumer<Thread,? super Throwable> c)
Define a hook that is executed when a
Scheduler has
handled an error. |
static void |
resetOnHandleError()
Reset the
onHandleError(BiConsumer) hook to the default no-op behavior. |
Disposable |
schedule(Runnable runnable) |
Disposable |
schedule(Runnable task,
long delay,
TimeUnit unit) |
Disposable |
schedulePeriodically(Runnable task,
long initialDelay,
long period,
TimeUnit unit) |
public static Scheduler create(String name)
Scheduler that hosts a fixed pool of single-threaded ExecutorService-based
workers and is suited for parallel work.name - Thread prefixScheduler that hosts a fixed pool of single-threaded
ExecutorService-based workers and is suited for parallel workpublic static Scheduler create(String name, int parallelism)
Scheduler that utilizes a ForkJoinPool for
workers and is suited for parallel work. Since the ForkJoinPool does not support
periodic or delayed scheduling, a single Scheduler is used to
enqueue any tasks that are delayed or periodicname - Thread prefixparallelism - Number of worker threadsScheduler that utilizes a ForkJoinPoolpublic static Scheduler create(int parallelism, ForkJoinPool.ForkJoinWorkerThreadFactory workerThreadFactory, Scheduler timeScheduler)
Scheduler that utilizes a ForkJoinPool for
workers and is suited for parallel work. Since the ForkJoinPool does not support
periodic or delayed scheduling, a single Scheduler is used to
enqueue any tasks that are delayed or periodicparallelism - Number of worker threadsworkerThreadFactory - factory for ForkJoinPool thradstimeScheduler - Scheduler to use for timed tasksScheduler that utilizes a ForkJoinPoolpublic static void onHandleError(java.util.function.BiConsumer<Thread,? super Throwable> c)
Scheduler has
handled an error. Note that it is executed after
the error has been passed to the thread uncaughtErrorHandler, which is not the
case when a fatal error occurs (see Exceptions.throwIfJvmFatal(Throwable)).c - the new hook to set.public static void resetOnHandleError()
onHandleError(BiConsumer) hook to the default no-op behavior.public Scheduler.Worker createWorker()
createWorker in interface Schedulerpublic void dispose()
dispose in interface Disposabledispose in interface Schedulerpublic boolean isDisposed()
isDisposed in interface Disposablepublic Disposable schedule(Runnable runnable)
public Disposable schedule(Runnable task, long delay, TimeUnit unit)
public Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit)
schedulePeriodically in interface Scheduler