org.apache.qpid.client.util
Class FlowControllingBlockingQueue
java.lang.Object
org.apache.qpid.client.util.FlowControllingBlockingQueue
public class FlowControllingBlockingQueue
- extends 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.
- Todo:
- Make this implement java.util.Queue and hide the implementation. Then different queue types can be substituted.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FlowControllingBlockingQueue
public FlowControllingBlockingQueue(int threshold,
FlowControllingBlockingQueue.ThresholdListener listener)
FlowControllingBlockingQueue
public FlowControllingBlockingQueue(int highThreshold,
int lowThreshold,
FlowControllingBlockingQueue.ThresholdListener listener)
isEmpty
public boolean isEmpty()
take
public Object take()
throws InterruptedException
- Throws:
InterruptedException
add
public void add(Object o)
iterator
public Iterator iterator()
Licensed to the Apache Software Foundation