Class AbstractScheduledService.CustomScheduler.ReschedulableCallable
java.lang.Object
com.google.common.util.concurrent.AbstractScheduledService.CustomScheduler.ReschedulableCallable
- Enclosing class:
AbstractScheduledService.CustomScheduler
private final class AbstractScheduledService.CustomScheduler.ReschedulableCallable
extends Object
implements Callable<Void>
A callable class that can reschedule itself using a
AbstractScheduledService.CustomScheduler
.-
Field Summary
FieldsModifier and TypeFieldDescriptionThe future that represents the next execution of this task.private final ScheduledExecutorService
The executor on which this Callable will be scheduled.private final ReentrantLock
This lock is used to ensure safe and correct cancellation, it ensures that a new task is not scheduled while a cancel is ongoing.private final AbstractService
The service that is managing this callable.private final Runnable
The underlying task. -
Constructor Summary
ConstructorsConstructorDescriptionReschedulableCallable
(AbstractService service, ScheduledExecutorService executor, Runnable runnable) -
Method Summary
Modifier and TypeMethodDescriptioncall()
Atomically reschedules this task and assigns the new future tocancellationDelegate
.private ScheduledFuture
<Void>
-
Field Details
-
wrappedRunnable
The underlying task. -
executor
The executor on which this Callable will be scheduled. -
service
The service that is managing this callable. This is used so that failure can be reported properly. -
lock
This lock is used to ensure safe and correct cancellation, it ensures that a new task is not scheduled while a cancel is ongoing. Also it protects the currentFuture variable to ensure that it is assigned atomically with being scheduled. -
cancellationDelegate
@CheckForNull private AbstractScheduledService.CustomScheduler.SupplantableFuture cancellationDelegateThe future that represents the next execution of this task.
-
-
Constructor Details
-
ReschedulableCallable
ReschedulableCallable(AbstractService service, ScheduledExecutorService executor, Runnable runnable)
-
-
Method Details
-
call
-
reschedule
Atomically reschedules this task and assigns the new future tocancellationDelegate
. -
initializeOrUpdateCancellationDelegate
private AbstractScheduledService.Cancellable initializeOrUpdateCancellationDelegate(AbstractScheduledService.CustomScheduler.Schedule schedule) -
submitToExecutor
private ScheduledFuture<Void> submitToExecutor(AbstractScheduledService.CustomScheduler.Schedule schedule)
-