com.ptc.windchill.upgrade.util
Class FixedLengthQueue

java.lang.Object
  extended bycom.ptc.windchill.upgrade.util.FixedLengthQueue

public class FixedLengthQueue
extends Object

Threadsafe queue of fixed length that blocks on put when queue is full until room frees up and blocks on get when queue is empty until an element is added.


Field Summary
private  Object[] elements_
           
private  int getIndex_
           
private  int numElements_
           
private  int putIndex_
           
 
Constructor Summary
FixedLengthQueue(int capacity)
          Create a queue with the specified maximum capacity.
 
Method Summary
 Object get()
          Gets the next element in the queue.
 int getCapacity()
          The largest number of elements that the queue can hold.
 int getCount()
          The number of elements currently in the queue.
 void put(Object o)
          Pushes a new element into the end of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elements_

private Object[] elements_

putIndex_

private int putIndex_

getIndex_

private int getIndex_

numElements_

private int numElements_
Constructor Detail

FixedLengthQueue

public FixedLengthQueue(int capacity)
                 throws IllegalArgumentException
Create a queue with the specified maximum capacity.

Throws:
IllegalArgumentException - if the capacity is set to zero or smaller
Method Detail

get

public Object get()
Gets the next element in the queue. Blocks when queue is empty until an element is added.


getCapacity

public int getCapacity()
The largest number of elements that the queue can hold.


getCount

public int getCount()
The number of elements currently in the queue.


put

public void put(Object o)
Pushes a new element into the end of the queue. Blocks when queue is full until an element is removed.