Class SizeBoundedQueue

java.lang.Object
org.jgroups.util.SizeBoundedQueue
All Implemented Interfaces:
Iterable, Collection, BlockingQueue, Queue

public class SizeBoundedQueue extends Object implements BlockingQueue
Queue as described in http://jira.jboss.com/jira/browse/JGRP-376. However, this queue only works with TP.IncomingPacket elements. The queue maintains a max number of bytes and a total of all of the messages in the internal queues. Whenever a message is added, we increment the total by the length of the message. When a message is removed, we decrement the total. Removal blocks until a message is available, addition blocks if the max size has been exceeded, until there is enough space to add another message. Note that the max size should always be greater than the size of the largest message to be received, otherwise an additon would always fail because msg.length > max size !
Access patterns: this instance is always accessed by the thread pool only ! Concurrent take() or poll() methods, but only a single thread at a time calls put() !
Version:
$Id: SizeBoundedQueue.java,v 1.3 2006/12/31 14:29:52 belaban Exp $
Author:
Bela Ban