Package alluxio.util.executor
Class ControllableQueue<T>
- java.lang.Object
-
- alluxio.util.executor.ControllableQueue<T>
-
- Type Parameters:
T
- the type of the value ofControllableQueue.DelayNode
public class ControllableQueue<T> extends java.lang.Object
A controllable queue is a priority queue withControllableQueue.DelayNode
s. It supports tick the time forward and pop nodes whose delay is smaller than the past time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ControllableQueue.DelayNode<T>
A delay node in delta queue which records the value and the total delay (which is the original delay plus the past time).
-
Constructor Summary
Constructors Constructor Description ControllableQueue()
Constructs a newControllableQueue
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long delay, T value)
Adds a new node into the queue.long
getHeadDelay()
T
getHeadValue()
boolean
isEmpty()
T
pop()
boolean
remove(T element)
Removes an element.void
tick(long duration)
Jumps to a future time period.java.lang.String
toString()
-
-
-
Constructor Detail
-
ControllableQueue
public ControllableQueue()
Constructs a newControllableQueue
.
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
- Returns:
- whether this queue is empty
-
getHeadValue
public T getHeadValue()
- Returns:
- the value of head element
-
getHeadDelay
public long getHeadDelay()
- Returns:
- the delay of head element
-
add
public void add(long delay, T value)
Adds a new node into the queue.- Parameters:
delay
- the delay in millisecondsvalue
- the value
-
tick
public void tick(long duration)
Jumps to a future time period.- Parameters:
duration
- the time period to jump
-
pop
public T pop()
- Returns:
- the head element if it should be executed
-
remove
public boolean remove(T element)
Removes an element.- Parameters:
element
- an element- Returns:
- true if the element removed successfully, false otherwise
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-