Class ScheduledFutureTask<V>

java.lang.Object
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 Details

    • id

      private long id
    • deadlineNanos

      private long deadlineNanos
    • periodNanos

      private final long periodNanos
    • queueIndex

      private int queueIndex
  • Constructor Details

  • Method Details

    • validatePeriod

      private static long validatePeriod(long period)
    • setId

      ScheduledFutureTask<V> setId(long id)
    • getId

      long getId()
    • 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 avoid StackOverflowError by executing a Runnable if the stack depth exceeds a threshold.

      Overrides:
      executor in class DefaultPromise<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 interface java.util.concurrent.Delayed
    • compareTo

      public int compareTo(java.util.concurrent.Delayed o)
      Specified by:
      compareTo in interface java.lang.Comparable<V>
    • run

      public void run()
      Specified by:
      run in interface java.lang.Runnable
      Specified by:
      run in interface java.util.concurrent.RunnableFuture<V>
      Overrides:
      run in class PromiseTask<V>
    • scheduledExecutor

      private AbstractScheduledEventExecutor scheduledExecutor()
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      If the cancellation was successful it will fail the future with a CancellationException.
      Specified by:
      cancel in interface Future<V>
      Specified by:
      cancel in interface java.util.concurrent.Future<V>
      Overrides:
      cancel in class PromiseTask<V>
      Parameters:
      mayInterruptIfRunning - this value has no effect in this implementation.
    • cancelWithoutRemove

      boolean cancelWithoutRemove(boolean mayInterruptIfRunning)
    • toStringBuilder

      protected java.lang.StringBuilder toStringBuilder()
      Overrides:
      toStringBuilder in class PromiseTask<V>
    • priorityQueueIndex

      public int priorityQueueIndex(DefaultPriorityQueue<?> queue)
      Description copied from interface: PriorityQueueNode
      Get the last value set by PriorityQueueNode.priorityQueueIndex(DefaultPriorityQueue, int) for the value corresponding to queue.

      Throwing exceptions from this method will result in undefined behavior.

      Specified by:
      priorityQueueIndex in interface PriorityQueueNode
    • priorityQueueIndex

      public void priorityQueueIndex(DefaultPriorityQueue<?> queue, int i)
      Description copied from interface: PriorityQueueNode
      Used by DefaultPriorityQueue to maintain state for an element in the queue.

      Throwing exceptions from this method will result in undefined behavior.

      Specified by:
      priorityQueueIndex in interface PriorityQueueNode
      Parameters:
      queue - The queue for which the index is being set.
      i - The index as used by DefaultPriorityQueue.