|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections.collection.SynchronizedCollection<E>
org.apache.commons.collections.buffer.SynchronizedBuffer<E>
org.apache.commons.collections.buffer.BlockingBuffer<E>
public class BlockingBuffer<E>
Decorates another Buffer
to make get()
and
remove()
block when the Buffer
is empty.
If either get
or remove
is called on an empty
Buffer
, the calling thread waits for notification that
an add
or addAll
operation has completed.
When one or more entries are added to an empty Buffer
,
all threads blocked in get
or remove
are notified.
There is no guarantee that concurrent blocked get
or
remove
requests will be "unblocked" and receive data in the
order that they arrive.
This class is Serializable from Commons Collections 3.1.
Field Summary |
---|
Fields inherited from class org.apache.commons.collections.collection.SynchronizedCollection |
---|
collection, lock |
Constructor Summary | |
---|---|
protected |
BlockingBuffer(Buffer<E> buffer)
Constructor that wraps (not copies). |
Method Summary | ||
---|---|---|
boolean |
add(E o)
|
|
boolean |
addAll(Collection<? extends E> c)
|
|
static
|
decorate(Buffer<E> buffer)
Factory method to create a blocking buffer. |
|
E |
get()
Gets the next object from the buffer without removing it. |
|
E |
remove()
Gets and removes the next object from the buffer. |
Methods inherited from class org.apache.commons.collections.buffer.SynchronizedBuffer |
---|
getBuffer |
Methods inherited from class org.apache.commons.collections.collection.SynchronizedCollection |
---|
clear, contains, containsAll, decorate, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Constructor Detail |
---|
protected BlockingBuffer(Buffer<E> buffer)
buffer
- the buffer to decorate, must not be null
IllegalArgumentException
- if the buffer is nullMethod Detail |
---|
public static <E> Buffer<E> decorate(Buffer<E> buffer)
buffer
- the buffer to decorate, must not be null
IllegalArgumentException
- if buffer is nullpublic boolean add(E o)
add
in interface Collection<E>
add
in class SynchronizedCollection<E>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E>
addAll
in class SynchronizedCollection<E>
public E get()
Buffer
get
in interface Buffer<E>
get
in class SynchronizedBuffer<E>
public E remove()
Buffer
remove
in interface Buffer<E>
remove
in class SynchronizedBuffer<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |