-
- All Superinterfaces:
Comparable<RunnableScheduledFuture<?>>,Future<V>,Runnable,RunnableFuture<V>
public interface RunnableScheduledFuture<V> extends RunnableFuture<V>, Comparable<RunnableScheduledFuture<?>>
A combination ofRunnableFutureandComparable(sorting by their next deadline), with additional methods for scheduling, periodicity, and delay.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <C> RunnableScheduledFuture<V>addListener(C context, FutureContextListener<? super C,? super V> listener)Adds the specified listener to this future.RunnableScheduledFuture<V>addListener(FutureListener<? super V> listener)Adds the specified listener to this future.booleancancel()Cancel this asynchronous operation, unless it has already been completed or is not cancellable.Throwablecause()Returns the cause of the failed operation if the operation has failed.longdeadlineNanos()Returns the deadline in nanos when theRunnable.run()method should be called again.longdelayNanos()Returns the delay in nanos when theRunnable.run()method should be called again.longdelayNanos(long currentTimeNanos)Returns the delay in nanos (taking the givencurrentTimeNanosinto account) when theRunnable.run()method should be called again.EventExecutorexecutor()VgetNow()Return the successful result of this asynchronous operation, if any.booleanisCancellable()Returnstrueif and only if the operation can be cancelled viacancel().booleanisCancelled()Returntrueif this operation has been cancelled.booleanisDone()Returntrueif this operation has been completed either successfully, unsuccessfully, or through cancellation.booleanisFailed()Returnstrueif and only if the operation was completed and failed.booleanisPeriodic()Returntrueif the task is periodic, which means it may be executed multiple times, as opposed to a delayed task or a normal task, that only execute once.booleanisSuccess()Returnstrueif and only if the operation was completed successfully.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
isPeriodic
boolean isPeriodic()
Returntrueif the task is periodic, which means it may be executed multiple times, as opposed to a delayed task or a normal task, that only execute once.- Returns:
trueif this task is periodic, otherwisefalse.
-
deadlineNanos
long deadlineNanos()
Returns the deadline in nanos when theRunnable.run()method should be called again.
-
delayNanos
long delayNanos()
Returns the delay in nanos when theRunnable.run()method should be called again.
-
delayNanos
long delayNanos(long currentTimeNanos)
Returns the delay in nanos (taking the givencurrentTimeNanosinto account) when theRunnable.run()method should be called again.
-
addListener
RunnableScheduledFuture<V> addListener(FutureListener<? super V> listener)
Description copied from interface:FutureAdds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.- Specified by:
addListenerin interfaceFuture<V>- Specified by:
addListenerin interfaceRunnableFuture<V>- Parameters:
listener- The listener to be called when this future completes. The listener will be passed this future as an argument.- Returns:
- this future object.
-
addListener
<C> RunnableScheduledFuture<V> addListener(C context, FutureContextListener<? super C,? super V> listener)
Description copied from interface:FutureAdds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.- Specified by:
addListenerin interfaceFuture<V>- Specified by:
addListenerin interfaceRunnableFuture<V>- Parameters:
context- The context object that will be passed to the listener when this future completes.listener- The listener to be called when this future completes. The listener will be passed the given context, and this future.- Returns:
- this future object.
-
cancel
boolean cancel()
Cancel this asynchronous operation, unless it has already been completed or is not cancellable.A cancelled operation is considered to be done and failed.
If the cancellation was successful, the result of this operation will be that it has failed with a
CancellationException.Cancellation will not cause any threads working on the operation to be interrupted.
- Returns:
trueif the operation was cancelled by this call, otherwisefalse.
-
isSuccess
boolean isSuccess()
Returnstrueif and only if the operation was completed successfully.
-
isFailed
boolean isFailed()
Returnstrueif and only if the operation was completed and failed.
-
isCancelled
boolean isCancelled()
Returntrueif this operation has been cancelled.- Returns:
trueif this operation has been cancelled, otherwisefalse.
-
isDone
boolean isDone()
Returntrueif this operation has been completed either successfully, unsuccessfully, or through cancellation.- Returns:
trueif this operation has completed, otherwisefalse.
-
isCancellable
boolean isCancellable()
Returnstrueif and only if the operation can be cancelled viacancel(). Note that this is inherently racy, as the operation could be made uncancellable at any time.- Returns:
trueif this operation can be cancelled.
-
getNow
V getNow()
Return the successful result of this asynchronous operation, if any. If the operation has not yet been completed, then this will throwIllegalStateException. If the operation has been cancelled or failed with an exception, then this returnsnull. Note that asynchronous operations can also be completed successfully with anullresult.- Returns:
- the result of this operation, if completed successfully.
- Throws:
IllegalStateException- if thisFutureorPromisehas not completed yet.
-
cause
Throwable cause()
Returns the cause of the failed operation if the operation has failed.- Returns:
- The cause of the failure, if any. Otherwise
nullif succeeded. - Throws:
IllegalStateException- if thisPromisehas not completed yet.
-
executor
EventExecutor executor()
-
-