org.apache.qpid.client.util
Class FlowControllingBlockingQueue

java.lang.Object
  extended by org.apache.qpid.client.util.FlowControllingBlockingQueue

public class FlowControllingBlockingQueue
extends java.lang.Object

A blocking queue that emits events above a user specified threshold allowing the caller to take action (e.g. flow control) to try to prevent the queue growing (much) further. The underlying queue itself is not bounded therefore the caller is not obliged to react to the events.

This implementation is only safe where we have a single thread adding items and a single (different) thread removing items.


Nested Class Summary
static interface FlowControllingBlockingQueue.ThresholdListener
           
 
Constructor Summary
FlowControllingBlockingQueue(int threshold, FlowControllingBlockingQueue.ThresholdListener listener)
           
FlowControllingBlockingQueue(int highThreshold, int lowThreshold, FlowControllingBlockingQueue.ThresholdListener listener)
           
 
Method Summary
 void add(java.lang.Object o)
           
 java.lang.Object take()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowControllingBlockingQueue

public FlowControllingBlockingQueue(int threshold,
                                    FlowControllingBlockingQueue.ThresholdListener listener)

FlowControllingBlockingQueue

public FlowControllingBlockingQueue(int highThreshold,
                                    int lowThreshold,
                                    FlowControllingBlockingQueue.ThresholdListener listener)
Method Detail

take

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

add

public void add(java.lang.Object o)