org.ros.internal.transport
Class CircularBlockingQueue<T>

java.lang.Object
  extended by org.ros.internal.transport.CircularBlockingQueue<T>

public class CircularBlockingQueue<T>
extends java.lang.Object

A BlockingQueue that removes the old elements when the number of elements exceeds the limit.


Constructor Summary
CircularBlockingQueue(int capacity)
           
 
Method Summary
 int getLimit()
           
 int getSize()
           
 void put(T entry)
           
 void setLimit(int limit)
          Adjusts the limit on the number of elements allowed in the queue.
 T take()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CircularBlockingQueue

public CircularBlockingQueue(int capacity)
Parameters:
capacity - the maximum number of elements allowed in the queue
Method Detail

setLimit

public void setLimit(int limit)
Adjusts the limit on the number of elements allowed in the queue. The limit must be less than the capacity and defaults to capacity - 1.

Parameters:
limit - the number of elements allowed in the queue

getLimit

public int getLimit()
Returns:
the number of elements allowed in the queue

getSize

public int getSize()
Returns:
the number of elements in the queue

put

public void put(T entry)
         throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

take

public T take()
       throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException