@Beta public abstract static class AbstractScheduledService.CustomScheduler extends AbstractScheduledService.Scheduler
AbstractScheduledService.Scheduler
that provides a convenient way for the AbstractScheduledService
to
use a dynamically changing schedule. After every execution of the task, assuming it hasn't been
cancelled, the getNextSchedule()
method will be called.Modifier and Type | Class and Description |
---|---|
private class |
AbstractScheduledService.CustomScheduler.ReschedulableCallable
A callable class that can reschedule itself using a
AbstractScheduledService.CustomScheduler . |
protected static class |
AbstractScheduledService.CustomScheduler.Schedule
A value object that represents an absolute delay until a task should be invoked.
|
Constructor and Description |
---|
CustomScheduler() |
Modifier and Type | Method and Description |
---|---|
protected abstract AbstractScheduledService.CustomScheduler.Schedule |
getNextSchedule()
Calculates the time at which to next invoke the task.
|
(package private) java.util.concurrent.Future<?> |
schedule(AbstractService service,
java.util.concurrent.ScheduledExecutorService executor,
java.lang.Runnable runnable)
Schedules the task to run on the provided executor on behalf of the service.
|
newFixedDelaySchedule, newFixedRateSchedule
final java.util.concurrent.Future<?> schedule(AbstractService service, java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable)
AbstractScheduledService.Scheduler
schedule
in class AbstractScheduledService.Scheduler
protected abstract AbstractScheduledService.CustomScheduler.Schedule getNextSchedule() throws java.lang.Exception
This is guaranteed to be called immediately after the task has completed an iteration and
on the same thread as the previous execution of AbstractScheduledService.runOneIteration()
.
java.lang.Exception