Class AbstractScheduledService.CustomScheduler
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractScheduledService.Scheduler
-
- com.google.common.util.concurrent.AbstractScheduledService.CustomScheduler
-
- Enclosing class:
- AbstractScheduledService
@Beta public abstract static class AbstractScheduledService.CustomScheduler extends AbstractScheduledService.Scheduler
AAbstractScheduledService.Scheduler
that provides a convenient way for theAbstractScheduledService
to use a dynamically changing schedule. After every execution of the task, assuming it hasn't been cancelled, thegetNextSchedule()
method will be called.- Since:
- 11.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
AbstractScheduledService.CustomScheduler.ReschedulableCallable
A callable class that can reschedule itself using aAbstractScheduledService.CustomScheduler
.protected static class
AbstractScheduledService.CustomScheduler.Schedule
A value object that represents an absolute delay until a task should be invoked.
-
Constructor Summary
Constructors Constructor Description CustomScheduler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.google.common.util.concurrent.AbstractScheduledService.Scheduler
newFixedDelaySchedule, newFixedRateSchedule
-
-
-
-
Method Detail
-
schedule
final java.util.concurrent.Future<?> schedule(AbstractService service, java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable)
Description copied from class:AbstractScheduledService.Scheduler
Schedules the task to run on the provided executor on behalf of the service.- Specified by:
schedule
in classAbstractScheduledService.Scheduler
-
getNextSchedule
protected abstract AbstractScheduledService.CustomScheduler.Schedule getNextSchedule() throws java.lang.Exception
Calculates the time at which to next invoke the task.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()
.- Returns:
- a schedule that defines the delay before the next execution.
- Throws:
java.lang.Exception
-
-