public interface WaiterScheduler
Abstraction for GenericWaiter
to implement the “schedule” functionality to implement
asynchronous waiting. Basically a cut down version of ScheduledExecutorService
, with only
the ScheduledExecutorService.schedule(Runnable, long, TimeUnit)
method.
Modifier and Type | Field and Description |
---|---|
static WaiterScheduler |
SYNC
Scheduler implementation that blocks in the
schedule(java.lang.Runnable, long, java.util.concurrent.TimeUnit) method for the given time to
pass. |
static WaiterScheduler |
UNSUPPORTED
A
WaiterScheduler where waiting is not supported. |
Modifier and Type | Method and Description |
---|---|
static WaiterScheduler |
fromService(ScheduledExecutorService service)
Create a new instance from the given
ScheduledExecutorService . |
Future<?> |
schedule(Runnable command,
long time,
TimeUnit unit) |
static final WaiterScheduler UNSUPPORTED
A WaiterScheduler
where waiting is not supported. Always throws an exception. GenericWaiter
will still succeed if the wait delay is configured as 0, but not if it’s
positive.
static final WaiterScheduler SYNC
Scheduler implementation that blocks in the schedule(java.lang.Runnable, long, java.util.concurrent.TimeUnit)
method for the given time to
pass. This removes the need for a separate threaded scheduler. GenericWaiter
can
handle the case where schedule(java.lang.Runnable, long, java.util.concurrent.TimeUnit)
blocks, so this will not deadlock or anything.
static WaiterScheduler fromService(ScheduledExecutorService service)
Create a new instance from the given ScheduledExecutorService
. Tasks will be run on
that executor.
Copyright © 2016–2024. All rights reserved.