Class ScheduledEventQueue


  • public class ScheduledEventQueue
    extends java.lang.Object
    Simple, lightweight event scheduler that does not maintain any executor threads of its own, but rather makes it the responsibility of the caller to run the events as the queue hands them over. Fully thread safe for multiple readers and writers.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Runnable getNextTask()
      Waits until the queue has a task that is ready for scheduling, removes that task from the queue and returns it.
      boolean isShutdown()  
      boolean isWaiting()  
      java.lang.Runnable popTask()
      If there is a task ready for scheduling, remove it from the queue and return it.
      void pushTask​(java.lang.Runnable task)  
      void pushTask​(java.lang.Runnable task, long milliSecondsToWait)  
      void shutdown()  
      long size()  
      void wakeTasks()
      For unit testing only
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScheduledEventQueue

        public ScheduledEventQueue()
      • ScheduledEventQueue

        public ScheduledEventQueue​(com.yahoo.concurrent.Timer timer)
    • Method Detail

      • pushTask

        public void pushTask​(java.lang.Runnable task)
      • pushTask

        public void pushTask​(java.lang.Runnable task,
                             long milliSecondsToWait)
      • isWaiting

        public boolean isWaiting()
      • getNextTask

        public java.lang.Runnable getNextTask()
        Waits until the queue has a task that is ready for scheduling, removes that task from the queue and returns it.
        Returns:
        The next task.
      • popTask

        public java.lang.Runnable popTask()
        If there is a task ready for scheduling, remove it from the queue and return it.
        Returns:
        The next task.
      • wakeTasks

        public void wakeTasks()
        For unit testing only
      • shutdown

        public void shutdown()
      • isShutdown

        public boolean isShutdown()
      • size

        public long size()