org.apache.commons.collections.buffer
Class BlockingBuffer<E>
java.lang.Object
org.apache.commons.collections.collection.SynchronizedCollection<E>
org.apache.commons.collections.buffer.SynchronizedBuffer<E>
org.apache.commons.collections.buffer.BlockingBuffer<E>
- All Implemented Interfaces:
- Serializable, Iterable<E>, Collection<E>, Buffer<E>
public class BlockingBuffer<E>
- extends SynchronizedBuffer<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.
- Since:
- Commons Collections 3.0
- Version:
- $Revision: 1.1.1.1 $ $Date: 2005/05/23 04:33:50 $
- Author:
- Stephen Colebourne, Janek Bogucki, Matt Hall, John Watkinson, Phil Steitz
- See Also:
- Serialized Form
|
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.collection.SynchronizedCollection |
clear, contains, containsAll, decorate, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
| Methods inherited from interface java.util.Collection |
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
BlockingBuffer
protected BlockingBuffer(Buffer<E> buffer)
- Constructor that wraps (not copies).
- Parameters:
buffer - the buffer to decorate, must not be null
- Throws:
IllegalArgumentException - if the buffer is null
decorate
public static <E> Buffer<E> decorate(Buffer<E> buffer)
- Factory method to create a blocking buffer.
- Parameters:
buffer - the buffer to decorate, must not be null
- Returns:
- a new blocking Buffer
- Throws:
IllegalArgumentException - if buffer is null
add
public boolean add(E o)
- Specified by:
add in interface Collection<E>- Overrides:
add in class SynchronizedCollection<E>
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll in interface Collection<E>- Overrides:
addAll in class SynchronizedCollection<E>
get
public E get()
- Description copied from interface:
Buffer
- Gets the next object from the buffer without removing it.
- Specified by:
get in interface Buffer<E>- Overrides:
get in class SynchronizedBuffer<E>
- Returns:
- the next object in the buffer, which is not removed
remove
public E remove()
- Description copied from interface:
Buffer
- Gets and removes the next object from the buffer.
- Specified by:
remove in interface Buffer<E>- Overrides:
remove in class SynchronizedBuffer<E>
- Returns:
- the next object in the buffer, which is also removed
Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.