net.floodlightcontroller.flowcache
Class PriorityPendingQueue<E>
java.lang.Object
net.floodlightcontroller.flowcache.PriorityPendingQueue<E>
public class PriorityPendingQueue<E>
- extends java.lang.Object
PriorityPendingQueue class - This class is a variant implementation for PriorityBlockingQueue
PriorityBlockingQueue implementation has two problems:
1. service for events with the same priority has no guarantee of FIFO sequence. This can be solved by override of comparator though.
2. PriorityBlockingQueue is implemented through heap, which has a O(log(n)) complexity for enqueue and dequeue operations.
to get a O(1) complexity with enqueue and dequeue operations, we propose this PriorityPendingList class.
PriorityPendingQueue has three separate queues: High Priority, Medium Priority and Low Priority.
the requirements here are:
1. dequeue from the Queue will always return the event with the highest priority
2. events with the same priority will be dequeued in their inserting order
3. enqueue and dequeue have O(1) complexity
current only support offer() and take() methods
- Author:
- meiyang
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PriorityPendingQueue
public PriorityPendingQueue()
take
public E take()
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
poll
public E poll()
peek
public E peek()
offer
public boolean offer(E e,
PriorityPendingQueue.EventPriority p)
offer
public boolean offer(E e)
size
public int size()
clear
public void clear()
isEmpty
public boolean isEmpty()