Package com.yahoo.documentapi.messagebus
Class ScheduledEventQueue
- java.lang.Object
-
- com.yahoo.documentapi.messagebus.ScheduledEventQueue
-
public class ScheduledEventQueue extends 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.
-
-
Constructor Summary
Constructors Constructor Description ScheduledEventQueue()
ScheduledEventQueue(com.yahoo.concurrent.Timer timer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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()
Runnable
popTask()
If there is a task ready for scheduling, remove it from the queue and return it.void
pushTask(Runnable task)
void
pushTask(Runnable task, long milliSecondsToWait)
void
shutdown()
long
size()
void
wakeTasks()
For unit testing only
-
-
-
Method Detail
-
pushTask
public void pushTask(Runnable task)
-
pushTask
public void pushTask(Runnable task, long milliSecondsToWait)
-
isWaiting
public boolean isWaiting()
-
getNextTask
public 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 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()
-
-