org.jikesrvm.adaptive.util
Class BlockingPriorityQueue

java.lang.Object
  extended by org.jikesrvm.util.PriorityQueueRVM
      extended by org.jikesrvm.adaptive.util.BlockingPriorityQueue

public class BlockingPriorityQueue
extends PriorityQueueRVM

This class extends PriorityQueueRVM to safely support multiple producers/consumers where the consumers are blocked if no objects are available to consume.


Nested Class Summary
static class BlockingPriorityQueue.CallBack
          Used to notify consumers when about to wait and when notified Default implementation does nothing, but can be overriden as needed by client.
 
Field Summary
(package private)  BlockingPriorityQueue.CallBack callback
           
 
Constructor Summary
BlockingPriorityQueue()
           
BlockingPriorityQueue(BlockingPriorityQueue.CallBack _cb)
           
 
Method Summary
 Object deleteMin()
          Remove and return the front (minimum) object.
 void insert(double _priority, Object _data)
          Insert the object passed with the priority value passed.
 
Methods inherited from class org.jikesrvm.util.PriorityQueueRVM
isEmpty, numElements, rootValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

callback

BlockingPriorityQueue.CallBack callback
Constructor Detail

BlockingPriorityQueue

public BlockingPriorityQueue(BlockingPriorityQueue.CallBack _cb)
Parameters:
_cb - the callback object

BlockingPriorityQueue

public BlockingPriorityQueue()
Method Detail

insert

public final void insert(double _priority,
                         Object _data)
Insert the object passed with the priority value passed.

Notify any sleeping consumer threads that an object is available for consumption.

Overrides:
insert in class PriorityQueueRVM
Parameters:
_priority - the priority to
_data - the object to insert

deleteMin

public final Object deleteMin()
Remove and return the front (minimum) object. If the queue is currently empty, then block until an object is available to be dequeued.

Overrides:
deleteMin in class PriorityQueueRVM
Returns:
the front (minimum) object.