Class AbstractScheduledService.CustomScheduler.ReschedulableCallable
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractScheduledService.CustomScheduler.ReschedulableCallable
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Void>
- Enclosing class:
- AbstractScheduledService.CustomScheduler
private final class AbstractScheduledService.CustomScheduler.ReschedulableCallable extends java.lang.Object implements java.util.concurrent.Callable<java.lang.Void>A callable class that can reschedule itself using aAbstractScheduledService.CustomScheduler.
-
-
Field Summary
Fields Modifier and Type Field Description private AbstractScheduledService.CustomScheduler.SupplantableFuturecancellationDelegateThe future that represents the next execution of this task.private java.util.concurrent.ScheduledExecutorServiceexecutorThe executor on which this Callable will be scheduled.private java.util.concurrent.locks.ReentrantLocklockThis lock is used to ensure safe and correct cancellation, it ensures that a new task is not scheduled while a cancel is ongoing.private AbstractServiceserviceThe service that is managing this callable.private java.lang.RunnablewrappedRunnableThe underlying task.
-
Constructor Summary
Constructors Constructor Description ReschedulableCallable(AbstractService service, java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Voidcall()private AbstractScheduledService.CancellableinitializeOrUpdateCancellationDelegate(AbstractScheduledService.CustomScheduler.Schedule schedule)AbstractScheduledService.Cancellablereschedule()Atomically reschedules this task and assigns the new future tocancellationDelegate.private java.util.concurrent.ScheduledFuture<java.lang.Void>submitToExecutor(AbstractScheduledService.CustomScheduler.Schedule schedule)
-
-
-
Field Detail
-
wrappedRunnable
private final java.lang.Runnable wrappedRunnable
The underlying task.
-
executor
private final java.util.concurrent.ScheduledExecutorService executor
The executor on which this Callable will be scheduled.
-
service
private final AbstractService service
The service that is managing this callable. This is used so that failure can be reported properly.
-
lock
private final java.util.concurrent.locks.ReentrantLock 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 cancellationDelegate
The future that represents the next execution of this task.
-
-
Constructor Detail
-
ReschedulableCallable
ReschedulableCallable(AbstractService service, java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable)
-
-
Method Detail
-
call
@CheckForNull public java.lang.Void call() throws java.lang.Exception- Specified by:
callin interfacejava.util.concurrent.Callable<java.lang.Void>- Throws:
java.lang.Exception
-
reschedule
public AbstractScheduledService.Cancellable reschedule()
Atomically reschedules this task and assigns the new future tocancellationDelegate.
-
initializeOrUpdateCancellationDelegate
private AbstractScheduledService.Cancellable initializeOrUpdateCancellationDelegate(AbstractScheduledService.CustomScheduler.Schedule schedule)
-
submitToExecutor
private java.util.concurrent.ScheduledFuture<java.lang.Void> submitToExecutor(AbstractScheduledService.CustomScheduler.Schedule schedule)
-
-