Class AbstractScheduledService.CustomScheduler
java.lang.Object
com.google.common.util.concurrent.AbstractScheduledService.Scheduler
com.google.common.util.concurrent.AbstractScheduledService.CustomScheduler
- Enclosing class:
- AbstractScheduledService
public abstract static class AbstractScheduledService.CustomScheduler
extends AbstractScheduledService.Scheduler
A
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.- Since:
- 11.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classA callable class that can reschedule itself using aAbstractScheduledService.CustomScheduler.protected static final classA value object that represents an absolute delay until a task should be invoked.private static final classContains the most recently submittedFuture, which may be cancelled or updated, always under a lock. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractScheduledService.CustomScheduler.ScheduleCalculates the time at which to next invoke the task.(package private) final AbstractScheduledService.Cancellableschedule(AbstractService service, ScheduledExecutorService executor, 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, newFixedDelaySchedule, newFixedRateSchedule, newFixedRateSchedule
-
Constructor Details
-
CustomScheduler
public CustomScheduler()
-
-
Method Details
-
schedule
final AbstractScheduledService.Cancellable schedule(AbstractService service, ScheduledExecutorService executor, Runnable runnable) Description copied from class:AbstractScheduledService.SchedulerSchedules the task to run on the provided executor on behalf of the service.- Specified by:
schedulein classAbstractScheduledService.Scheduler
-
getNextSchedule
protected abstract AbstractScheduledService.CustomScheduler.Schedule getNextSchedule() throws ExceptionCalculates 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:
Exception
-