java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingQueue, java.util.Queue<E>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 | Description |
|---|---|
SizeBoundedQueue() |
| Modifier and Type | Method | 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.concurrent.BlockingQueueadd in interface java.util.Collection<E extends java.lang.Object>add in interface java.util.Queue<E extends java.lang.Object>public 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.Queue<E extends java.lang.Object>public 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.Queue<E extends java.lang.Object>public java.lang.Object peek()
peek in interface java.util.Queue<E extends java.lang.Object>public java.lang.Object poll()
poll in interface java.util.Queue<E extends java.lang.Object>public java.lang.Object remove()
remove in interface java.util.Queue<E extends java.lang.Object>public boolean addAll(java.util.Collection c)
addAll in interface java.util.Collection<E extends java.lang.Object>public void clear()
clear in interface java.util.Collection<E extends java.lang.Object>public boolean contains(java.lang.Object o)
contains in interface java.util.concurrent.BlockingQueuecontains in interface java.util.Collection<E extends java.lang.Object>public boolean containsAll(java.util.Collection c)
containsAll in interface java.util.Collection<E extends java.lang.Object>public boolean isEmpty()
isEmpty in interface java.util.Collection<E extends java.lang.Object>public java.util.Iterator iterator()
iterator in interface java.util.Collection<E extends java.lang.Object>iterator in interface java.lang.Iterable<E extends java.lang.Object>public boolean remove(java.lang.Object o)
remove in interface java.util.concurrent.BlockingQueueremove in interface java.util.Collection<E extends java.lang.Object>public boolean removeAll(java.util.Collection c)
removeAll in interface java.util.Collection<E extends java.lang.Object>public boolean retainAll(java.util.Collection c)
retainAll in interface java.util.Collection<E extends java.lang.Object>public int size()
size in interface java.util.Collection<E extends java.lang.Object>public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E extends java.lang.Object>public java.lang.Object[] toArray(java.lang.Object[] a)
toArray in interface java.util.Collection<E extends java.lang.Object>Copyright ? 1998-2008 Bela Ban. All Rights Reserved.