private class AbstractScheduledService.CustomScheduler.ReschedulableCallable extends ForwardingFuture<java.lang.Void> implements java.util.concurrent.Callable<java.lang.Void>
AbstractScheduledService.CustomScheduler.ForwardingFuture.SimpleForwardingFuture<V>| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.Future<java.lang.Void> |
currentFuture
The future that represents the next execution of this task.
|
private java.util.concurrent.ScheduledExecutorService |
executor
The executor on which this Callable will be scheduled.
|
private 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.
|
private AbstractService |
service
The service that is managing this callable.
|
private java.lang.Runnable |
wrappedRunnable
The underlying task.
|
| Constructor and Description |
|---|
ReschedulableCallable(AbstractService service,
java.util.concurrent.ScheduledExecutorService executor,
java.lang.Runnable runnable) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Void |
call() |
boolean |
cancel(boolean mayInterruptIfRunning) |
protected java.util.concurrent.Future<java.lang.Void> |
delegate()
Returns the backing delegate instance that methods are forwarded to.
|
boolean |
isCancelled() |
void |
reschedule()
Atomically reschedules this task and assigns the new future to
currentFuture. |
get, get, isDonetoStringprivate final java.lang.Runnable wrappedRunnable
private final java.util.concurrent.ScheduledExecutorService executor
private final AbstractService service
private final java.util.concurrent.locks.ReentrantLock lock
private java.util.concurrent.Future<java.lang.Void> currentFuture
ReschedulableCallable(AbstractService service, java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable)
public java.lang.Void call()
throws java.lang.Exception
call in interface java.util.concurrent.Callable<java.lang.Void>java.lang.Exceptionpublic void reschedule()
currentFuture.public boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<java.lang.Void>cancel in class ForwardingFuture<java.lang.Void>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<java.lang.Void>isCancelled in class ForwardingFuture<java.lang.Void>protected java.util.concurrent.Future<java.lang.Void> delegate()
ForwardingObjectForwardingSet.delegate(). Concrete subclasses override this method to supply the
instance being decorated.delegate in class ForwardingFuture<java.lang.Void>