org.apache.commons.collections.buffer

Class BlockingBuffer

public class BlockingBuffer extends SynchronizedBuffer

Decorates another Buffer to make {@link #get()} and {@link #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.7 $ $Date: 2004/06/03 22:02:13 $

Author: Stephen Colebourne Janek Bogucki Phil Steitz

Constructor Summary
protected BlockingBuffer(Buffer buffer)
Constructor that wraps (not copies).
Method Summary
booleanadd(Object o)
booleanaddAll(Collection c)
static Bufferdecorate(Buffer buffer)
Factory method to create a blocking buffer.
Objectget()
Objectremove()

Constructor Detail

BlockingBuffer

protected BlockingBuffer(Buffer buffer)
Constructor that wraps (not copies).

Parameters: buffer the buffer to decorate, must not be null

Throws: IllegalArgumentException if the buffer is null

Method Detail

add

public boolean add(Object o)

addAll

public boolean addAll(Collection c)

decorate

public static Buffer decorate(Buffer 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

get

public Object get()

remove

public Object remove()
Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.