Package io.netty.util.concurrent
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
,Comparable<Delayed>
,Runnable
,Delayed
,Future<V>
,RunnableFuture<V>
,ScheduledFuture<V>
final class ScheduledFutureTask<V>
extends PromiseTask<V>
implements ScheduledFuture<V>, PriorityQueueNode
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private long
private final long
private int
Fields inherited from interface io.netty.util.internal.PriorityQueueNode
INDEX_NOT_IN_QUEUE
-
Constructor Summary
ConstructorsConstructorDescriptionScheduledFutureTask
(AbstractScheduledEventExecutor executor, Runnable runnable, long nanoTime) ScheduledFutureTask
(AbstractScheduledEventExecutor executor, Runnable runnable, long nanoTime, long period) ScheduledFutureTask
(AbstractScheduledEventExecutor executor, Callable<V> callable, long nanoTime) ScheduledFutureTask
(AbstractScheduledEventExecutor executor, Callable<V> callable, long nanoTime, long period) -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException
.(package private) boolean
cancelWithoutRemove
(boolean mayInterruptIfRunning) int
long
(package private) static long
deadlineToDelayNanos
(long currentTimeNanos, long deadlineNanos) long
long
delayNanos
(long currentTimeNanos) protected EventExecutor
executor()
Get the executor used to notify listeners when this promise is complete.long
int
priorityQueueIndex
(DefaultPriorityQueue<?> queue) Get the last value set byPriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int)
for the value corresponding toqueue
.void
priorityQueueIndex
(DefaultPriorityQueue<?> queue, int i) Used byDefaultPriorityQueue
to maintain state for an element in the queue.void
run()
private AbstractScheduledEventExecutor
(package private) void
(package private) ScheduledFutureTask
<V> setId
(long id) protected StringBuilder
private static long
validatePeriod
(long period) Methods inherited from class io.netty.util.concurrent.PromiseTask
equals, hashCode, runTask, setFailure, setFailureInternal, setSuccess, setSuccessInternal, setUncancellable, setUncancellableInternal, tryFailure, tryFailureInternal, trySuccess, trySuccessInternal
Methods inherited from class io.netty.util.concurrent.DefaultPromise
addListener, addListeners, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, cause, checkDeadLock, get, get, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, notifyProgressiveListeners, removeListener, removeListeners, sync, syncUninterruptibly, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.util.concurrent.Future
await, await, awaitUninterruptibly, awaitUninterruptibly, cause, getNow, isCancellable, isSuccess
Methods inherited from interface java.util.concurrent.Future
exceptionNow, get, get, isCancelled, isDone, resultNow, state
-
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, Runnable runnable, long nanoTime) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, Runnable runnable, long nanoTime, long period) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, Callable<V> callable, long nanoTime, long period) -
ScheduledFutureTask
ScheduledFutureTask(AbstractScheduledEventExecutor executor, Callable<V> callable, long nanoTime)
-
-
Method Details
-
validatePeriod
private static long validatePeriod(long period) -
setId
-
executor
Description copied from class:DefaultPromise
Get the executor used to notify listeners when this promise is complete.It is assumed this executor will protect against
StackOverflowError
exceptions. The executor may be used to avoidStackOverflowError
by executing aRunnable
if the stack depth exceeds a threshold.- Overrides:
executor
in 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
-
compareTo
- Specified by:
compareTo
in interfaceComparable<V>
-
run
public void run()- Specified by:
run
in interfaceRunnable
- Specified by:
run
in interfaceRunnableFuture<V>
- Overrides:
run
in 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
- Overrides:
toStringBuilder
in classPromiseTask<V>
-
priorityQueueIndex
Description copied from interface:PriorityQueueNode
Get 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:
priorityQueueIndex
in interfacePriorityQueueNode
-
priorityQueueIndex
Description copied from interface:PriorityQueueNode
Used byDefaultPriorityQueue
to maintain state for an element in the queue.Throwing exceptions from this method will result in undefined behavior.
- Specified by:
priorityQueueIndex
in interfacePriorityQueueNode
- Parameters:
queue
- The queue for which the index is being set.i
- The index as used byDefaultPriorityQueue
.
-