public class SizeBoundedQueue
extends java.lang.Object
implements java.util.concurrent.BlockingQueue
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 !| Constructor and Description |
|---|
SizeBoundedQueue() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Object o) |
boolean |
addAll(java.util.Collection c) |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection c) |
int |
drainTo(java.util.Collection c) |
int |
drainTo(java.util.Collection c,
int maxElements) |
java.lang.Object |
element() |
boolean |
isEmpty() |
java.util.Iterator |
iterator() |
boolean |
offer(java.lang.Object o) |
boolean |
offer(java.lang.Object o,
long timeout,
java.util.concurrent.TimeUnit unit) |
java.lang.Object |
peek() |
java.lang.Object |
poll() |
java.lang.Object |
poll(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
put(java.lang.Object o) |
int |
remainingCapacity() |
java.lang.Object |
remove() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection c) |
boolean |
retainAll(java.util.Collection c) |
int |
size() |
java.lang.Object |
take() |
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
public boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in interface java.util.concurrent.BlockingQueueadd in interface java.util.Queuepublic int drainTo(java.util.Collection c)
drainTo in interface java.util.concurrent.BlockingQueuepublic int drainTo(java.util.Collection c,
int maxElements)
drainTo in interface java.util.concurrent.BlockingQueuepublic boolean offer(java.lang.Object o)
offer in interface java.util.concurrent.BlockingQueueoffer in interface java.util.Queuepublic boolean offer(java.lang.Object o,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
offer in interface java.util.concurrent.BlockingQueuejava.lang.InterruptedExceptionpublic java.lang.Object poll(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
poll in interface java.util.concurrent.BlockingQueuejava.lang.InterruptedExceptionpublic void put(java.lang.Object o)
throws java.lang.InterruptedException
put in interface java.util.concurrent.BlockingQueuejava.lang.InterruptedExceptionpublic int remainingCapacity()
remainingCapacity in interface java.util.concurrent.BlockingQueuepublic java.lang.Object take()
throws java.lang.InterruptedException
take in interface java.util.concurrent.BlockingQueuejava.lang.InterruptedExceptionpublic java.lang.Object element()
element in interface java.util.Queuepublic java.lang.Object peek()
peek in interface java.util.Queuepublic java.lang.Object poll()
poll in interface java.util.Queuepublic java.lang.Object remove()
remove in interface java.util.Queuepublic boolean addAll(java.util.Collection c)
addAll in interface java.util.Collectionpublic void clear()
clear in interface java.util.Collectionpublic boolean contains(java.lang.Object o)
contains in interface java.util.Collectioncontains in interface java.util.concurrent.BlockingQueuepublic boolean containsAll(java.util.Collection c)
containsAll in interface java.util.Collectionpublic boolean isEmpty()
isEmpty in interface java.util.Collectionpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectionpublic boolean remove(java.lang.Object o)
remove in interface java.util.Collectionremove in interface java.util.concurrent.BlockingQueuepublic boolean removeAll(java.util.Collection c)
removeAll in interface java.util.Collectionpublic boolean retainAll(java.util.Collection c)
retainAll in interface java.util.Collectionpublic int size()
size in interface java.util.Collectionpublic java.lang.Object[] toArray()
toArray in interface java.util.Collectionpublic java.lang.Object[] toArray(java.lang.Object[] a)
toArray in interface java.util.CollectionCopyright ? 1998-2008 Bela Ban. All Rights Reserved.