Class ScheduledFutureTask<V>
java.lang.Object
io.netty.util.concurrent.AbstractFuture<V>
io.netty.util.concurrent.DefaultPromise<V>
io.netty.util.concurrent.PromiseTask<V>
io.netty.util.concurrent.ScheduledFutureTask<V>
- All Implemented Interfaces:
Future<V>, Promise<V>, ScheduledFuture<V>, PriorityQueueNode, java.lang.Comparable<java.util.concurrent.Delayed>, java.lang.Runnable, java.util.concurrent.Delayed, java.util.concurrent.Future<V>, java.util.concurrent.RunnableFuture<V>, java.util.concurrent.ScheduledFuture<V>
final class ScheduledFutureTask<V>
extends PromiseTask<V>
implements ScheduledFuture<V>, PriorityQueueNode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate longprivate final longprivate intFields inherited from class DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTHFields inherited from interface PriorityQueueNode
INDEX_NOT_IN_QUEUE -
Constructor Summary
ConstructorsConstructorDescriptionScheduledFutureTask(AbstractScheduledEventExecutor executor, java.lang.Runnable runnable, long nanoTime) ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.lang.Runnable runnable, long nanoTime, long period) ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.util.concurrent.Callable<V> callable, long nanoTime) ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.util.concurrent.Callable<V> callable, long nanoTime, long period) -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException.(package private) booleancancelWithoutRemove(boolean mayInterruptIfRunning) intcompareTo(java.util.concurrent.Delayed o) long(package private) static longdeadlineToDelayNanos(long currentTimeNanos, long deadlineNanos) longlongdelayNanos(long currentTimeNanos) protected EventExecutorexecutor()Get the executor used to notify listeners when this promise is complete.longgetDelay(java.util.concurrent.TimeUnit unit) (package private) longgetId()intpriorityQueueIndex(DefaultPriorityQueue<?> queue) Get the last value set byPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int)for the value corresponding toqueue.voidpriorityQueueIndex(DefaultPriorityQueue<?> queue, int i) Used byDefaultPriorityQueueto maintain state for an element in the queue.voidrun()private AbstractScheduledEventExecutor(package private) void(package private) ScheduledFutureTask<V> setId(long id) protected java.lang.StringBuilderprivate static longvalidatePeriod(long period) Methods inherited from class PromiseTask
equals, hashCode, runTask, setFailure, setFailureInternal, setSuccess, setSuccessInternal, setUncancellable, setUncancellableInternal, tryFailure, tryFailureInternal, trySuccess, trySuccessInternalMethods inherited from class DefaultPromise
addListener, addListeners, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, cause, checkDeadLock, get, get, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, notifyProgressiveListeners, removeListener, removeListeners, sync, syncUninterruptibly, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface Future
await, await, awaitUninterruptibly, awaitUninterruptibly, cause, getNow, isCancellable, isSuccessMethods inherited from interface java.util.concurrent.Future
get, get, isCancelled, isDone
-
Field Details
-
id
private long id -
deadlineNanos
private long deadlineNanos -
periodNanos
private final long periodNanos -
queueIndex
private int queueIndex
-
-
Constructor Details
-
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.lang.Runnable runnable, long nanoTime) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.lang.Runnable runnable, long nanoTime, long period) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.util.concurrent.Callable<V> callable, long nanoTime, long period) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, java.util.concurrent.Callable<V> callable, long nanoTime)
-
-
Method Details
-
validatePeriod
private static long validatePeriod(long period) -
setId
-
getId
long getId() -
executor
Description copied from class:DefaultPromiseGet the executor used to notify listeners when this promise is complete.It is assumed this executor will protect against
StackOverflowErrorexceptions. The executor may be used to avoidStackOverflowErrorby executing aRunnableif the stack depth exceeds a threshold.- Overrides:
executorin classDefaultPromise<V>- Returns:
- The executor used to notify listeners when this promise is complete.
-
deadlineNanos
public long deadlineNanos() -
setConsumed
void setConsumed() -
delayNanos
public long delayNanos() -
deadlineToDelayNanos
static long deadlineToDelayNanos(long currentTimeNanos, long deadlineNanos) -
delayNanos
public long delayNanos(long currentTimeNanos) -
getDelay
public long getDelay(java.util.concurrent.TimeUnit unit) - Specified by:
getDelayin interfacejava.util.concurrent.Delayed
-
compareTo
public int compareTo(java.util.concurrent.Delayed o) - Specified by:
compareToin interfacejava.lang.Comparable<V>
-
run
public void run()- Specified by:
runin interfacejava.lang.Runnable- Specified by:
runin interfacejava.util.concurrent.RunnableFuture<V>- Overrides:
runin classPromiseTask<V>
-
scheduledExecutor
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException. -
cancelWithoutRemove
boolean cancelWithoutRemove(boolean mayInterruptIfRunning) -
toStringBuilder
protected java.lang.StringBuilder toStringBuilder()- Overrides:
toStringBuilderin classPromiseTask<V>
-
priorityQueueIndex
Description copied from interface:PriorityQueueNodeGet the last value set byPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int)for the value corresponding toqueue.Throwing exceptions from this method will result in undefined behavior.
- Specified by:
priorityQueueIndexin interfacePriorityQueueNode
-
priorityQueueIndex
Description copied from interface:PriorityQueueNodeUsed byDefaultPriorityQueueto maintain state for an element in the queue.Throwing exceptions from this method will result in undefined behavior.
- Specified by:
priorityQueueIndexin interfacePriorityQueueNode- Parameters:
queue- The queue for which the index is being set.i- The index as used byDefaultPriorityQueue.
-