public static class PriorityDelayQueue.QueueElement<E> extends FutureTask<E> implements Delayed
This wrapper keeps track of the priority and the age of a queue element.
Constructor and Description |
---|
QueueElement(XCallable<E> element,
int priority,
long delay,
TimeUnit unit)
Create an Element wrapper.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Delayed o)
Compare the age of this wrapper element with another.
|
long |
getDelay(TimeUnit unit)
Return the delay of the element.
|
XCallable<E> |
getElement()
Return the element from the wrapper.
|
int |
getPriority()
Return the priority of the element.
|
void |
setDelay(long delay,
TimeUnit unit)
Set the delay of the element.
|
String |
toString()
Return the string representation of the wrapper element.
|
cancel, done, get, get, isCancelled, isDone, run, runAndReset, set, setException
public QueueElement(XCallable<E> element, int priority, long delay, TimeUnit unit)
element
- element.priority
- priority of the element.delay
- delay of the element.unit
- time unit of the delay.IllegalArgumentException
- if the element is NULL, the priority is negative or if the delay is
negative.public XCallable<E> getElement()
public int getPriority()
public void setDelay(long delay, TimeUnit unit)
delay
- delay of the element.unit
- time unit of the delay.public int compareTo(Delayed o)
compareTo
in interface Comparable<Delayed>
o
- the other wrapper element to compare with.Copyright © 2018 Apache Software Foundation. All rights reserved.