Class AbstractScheduledEventExecutor

    • Field Detail

      • SCHEDULED_FUTURE_TASK_COMPARATOR

        private static final java.util.Comparator<ScheduledFutureTask<?>> SCHEDULED_FUTURE_TASK_COMPARATOR
      • WAKEUP_TASK

        static final java.lang.Runnable WAKEUP_TASK
      • nextTaskId

        long nextTaskId
    • Constructor Detail

      • AbstractScheduledEventExecutor

        protected AbstractScheduledEventExecutor()
      • AbstractScheduledEventExecutor

        protected AbstractScheduledEventExecutor​(EventExecutorGroup parent)
    • Method Detail

      • nanoTime

        protected static long nanoTime()
      • deadlineToDelayNanos

        protected static long deadlineToDelayNanos​(long deadlineNanos)
        Given an arbitrary deadline deadlineNanos, calculate the number of nano seconds from now deadlineNanos would expire.
        Parameters:
        deadlineNanos - An arbitrary deadline in nano seconds.
        Returns:
        the number of nano seconds from now deadlineNanos would expire.
      • initialNanoTime

        protected static long initialNanoTime()
        The initial value used for delay and computations based upon a monatomic time source.
        Returns:
        initial value used for delay and computations based upon a monatomic time source.
      • isNullOrEmpty

        private static boolean isNullOrEmpty​(java.util.Queue<ScheduledFutureTask<?>> queue)
      • pollScheduledTask

        protected final java.lang.Runnable pollScheduledTask​(long nanoTime)
        Return the Runnable which is ready to be executed with the given nanoTime. You should use nanoTime() to retrieve the correct nanoTime.
      • nextScheduledTaskNano

        protected final long nextScheduledTaskNano()
        Return the nanoseconds until the next scheduled task is ready to be run or -1 if no task is scheduled.
      • nextScheduledTaskDeadlineNanos

        protected final long nextScheduledTaskDeadlineNanos()
        Return the deadline (in nanoseconds) when the next scheduled task is ready to be run or -1 if no task is scheduled.
      • hasScheduledTasks

        protected final boolean hasScheduledTasks()
        Returns true if a scheduled task is ready for processing.
      • validateScheduled0

        private void validateScheduled0​(long amount,
                                        java.util.concurrent.TimeUnit unit)
      • validateScheduled

        @Deprecated
        protected void validateScheduled​(long amount,
                                         java.util.concurrent.TimeUnit unit)
        Deprecated.
        will be removed in the future.
        Sub-classes may override this to restrict the maximal amount of time someone can use to schedule a task.
      • beforeScheduledTaskSubmitted

        protected boolean beforeScheduledTaskSubmitted​(long deadlineNanos)
        Called from arbitrary non-EventExecutor threads prior to scheduled task submission. Returns true if the EventExecutor thread should be woken immediately to process the scheduled task (if not already awake).

        If false is returned, afterScheduledTaskSubmitted(long) will be called with the same value after the scheduled task is enqueued, providing another opportunity to wake the EventExecutor thread if required.

        Parameters:
        deadlineNanos - deadline of the to-be-scheduled task relative to nanoTime()
        Returns:
        true if the EventExecutor thread should be woken, false otherwise
      • afterScheduledTaskSubmitted

        protected boolean afterScheduledTaskSubmitted​(long deadlineNanos)
        See beforeScheduledTaskSubmitted(long). Called only after that method returns false.
        Parameters:
        deadlineNanos - relative to nanoTime()
        Returns:
        true if the EventExecutor thread should be woken, false otherwise