Package dev.failsafe.internal.util
Class DelegatingScheduler
- java.lang.Object
-
- dev.failsafe.internal.util.DelegatingScheduler
-
- All Implemented Interfaces:
Scheduler
public final class DelegatingScheduler extends java.lang.Object implements Scheduler
AScheduler
implementation that schedules delays on an internal, common ScheduledExecutorService and executes tasks on either a providedExecutorService
,ForkJoinPool.commonPool()
, or an internalForkJoinPool
instance. If noExecutorService
is supplied, theForkJoinPool.commonPool()
will be used, unless the common pool's parallelism is 1, then an internalForkJoinPool
with parallelism of 2 will be created and used.Supports cancellation and interruption of
ForkJoinPool
tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
DelegatingScheduler.DelayerThreadFactory
(package private) static class
DelegatingScheduler.ScheduledCompletableFuture<V>
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.ScheduledThreadPoolExecutor
DELAYER
private java.util.concurrent.ExecutorService
executorService
private static java.util.concurrent.ForkJoinPool
FORK_JOIN_POOL
static DelegatingScheduler
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
DelegatingScheduler()
DelegatingScheduler(java.util.concurrent.ExecutorService executor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.concurrent.ScheduledExecutorService
delayer()
private java.util.concurrent.ExecutorService
executorService()
java.util.concurrent.ScheduledFuture<?>
schedule(java.util.concurrent.Callable<?> callable, long delay, java.util.concurrent.TimeUnit unit)
Schedules thecallable
to be called after thedelay
for theunit
.
-
-
-
Field Detail
-
INSTANCE
public static final DelegatingScheduler INSTANCE
-
FORK_JOIN_POOL
private static volatile java.util.concurrent.ForkJoinPool FORK_JOIN_POOL
-
DELAYER
private static volatile java.util.concurrent.ScheduledThreadPoolExecutor DELAYER
-
executorService
private final java.util.concurrent.ExecutorService executorService
-
-
Method Detail
-
delayer
private static java.util.concurrent.ScheduledExecutorService delayer()
-
executorService
private java.util.concurrent.ExecutorService executorService()
-
schedule
public java.util.concurrent.ScheduledFuture<?> schedule(java.util.concurrent.Callable<?> callable, long delay, java.util.concurrent.TimeUnit unit)
Description copied from interface:Scheduler
Schedules thecallable
to be called after thedelay
for theunit
.
-
-