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
,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
Fields Modifier and Type Field Description private long
deadlineNanos
private long
id
private long
periodNanos
private int
queueIndex
-
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
Fields inherited from interface io.netty.util.internal.PriorityQueueNode
INDEX_NOT_IN_QUEUE
-
-
Constructor Summary
Constructors Constructor Description ScheduledFutureTask(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
If the cancellation was successful it will fail the future with aCancellationException
.(package private) boolean
cancelWithoutRemove(boolean mayInterruptIfRunning)
int
compareTo(java.util.concurrent.Delayed o)
long
deadlineNanos()
(package private) static long
deadlineToDelayNanos(long currentTimeNanos, long deadlineNanos)
long
delayNanos()
long
delayNanos(long currentTimeNanos)
protected EventExecutor
executor()
Get the executor used to notify listeners when this promise is complete.long
getDelay(java.util.concurrent.TimeUnit unit)
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
scheduledExecutor()
(package private) void
setConsumed()
(package private) ScheduledFutureTask<V>
setId(long id)
protected java.lang.StringBuilder
toStringBuilder()
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
-
-
-
-
Constructor Detail
-
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 Detail
-
validatePeriod
private static long validatePeriod(long period)
-
setId
ScheduledFutureTask<V> setId(long id)
-
executor
protected EventExecutor 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
public long getDelay(java.util.concurrent.TimeUnit unit)
- Specified by:
getDelay
in interfacejava.util.concurrent.Delayed
-
compareTo
public int compareTo(java.util.concurrent.Delayed o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<V>
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in interfacejava.util.concurrent.RunnableFuture<V>
- Overrides:
run
in classPromiseTask<V>
-
scheduledExecutor
private AbstractScheduledEventExecutor 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:
toStringBuilder
in classPromiseTask<V>
-
priorityQueueIndex
public int priorityQueueIndex(DefaultPriorityQueue<?> queue)
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
public void priorityQueueIndex(DefaultPriorityQueue<?> queue, int i)
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
.
-
-