| org.apache.commons.collections.buffer.SynchronizedBuffer org.apache.commons.collections.buffer.BlockingBuffer
BlockingBuffer | public class BlockingBuffer extends SynchronizedBuffer (Code) | | Decorates another Buffer to make
BlockingBuffer.get() and
BlockingBuffer.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.
This class contains an extra field in 3.2, however the serialization
specification will handle this gracefully.
author: Stephen Colebourne author: Janek Bogucki author: Phil Steitz author: James Carman version: $Revision: 348808 $ $Date: 2005-11-24 21:35:09 +0000 (Thu, 24 Nov 2005) $ since: Commons Collections 3.0 |
Method Summary | |
public boolean | add(Object o) | public boolean | addAll(Collection c) | public static Buffer | decorate(Buffer buffer) Factory method to create a blocking buffer. | public static Buffer | decorate(Buffer buffer, long timeoutMillis) Factory method to create a blocking buffer with a timeout value. | public Object | get() Gets the next value from the buffer, waiting until an object is
added if the buffer is empty. | public Object | get(long timeout) Gets the next value from the buffer, waiting until an object is
added for up to the specified timeout value if the buffer is empty. | public Object | remove() Removes the next value from the buffer, waiting until an object is
added if the buffer is empty. | public Object | remove(long timeout) Removes the next value from the buffer, waiting until an object is
added for up to the specified timeout value if the buffer is empty. |
BlockingBuffer | protected BlockingBuffer(Buffer buffer)(Code) | | Constructor that wraps (not copies).
Parameters: buffer - the buffer to decorate, must not be null throws: IllegalArgumentException - if the buffer is null |
BlockingBuffer | protected BlockingBuffer(Buffer buffer, long timeoutMillis)(Code) | | Constructor that wraps (not copies).
Parameters: buffer - the buffer to decorate, must not be null Parameters: timeoutMillis - the timeout value in milliseconds, zero or less for no timeout throws: IllegalArgumentException - if the buffer is null since: Commons Collections 3.2 |
decorate | public static Buffer decorate(Buffer buffer)(Code) | | Factory method to create a blocking buffer.
Parameters: buffer - the buffer to decorate, must not be null a new blocking Buffer throws: IllegalArgumentException - if buffer is null |
decorate | public static Buffer decorate(Buffer buffer, long timeoutMillis)(Code) | | Factory method to create a blocking buffer with a timeout value.
Parameters: buffer - the buffer to decorate, must not be null Parameters: timeoutMillis - the timeout value in milliseconds, zero or less for no timeout a new blocking buffer throws: IllegalArgumentException - if the buffer is null since: Commons Collections 3.2 |
get | public Object get()(Code) | | Gets the next value from the buffer, waiting until an object is
added if the buffer is empty. This method uses the default timeout
set in the constructor.
throws: BufferUnderflowException - if an interrupt is received |
get | public Object get(long timeout)(Code) | | Gets the next value from the buffer, waiting until an object is
added for up to the specified timeout value if the buffer is empty.
Parameters: timeout - the timeout value in milliseconds throws: BufferUnderflowException - if an interrupt is received throws: BufferUnderflowException - if the timeout expires since: Commons Collections 3.2 |
remove | public Object remove()(Code) | | Removes the next value from the buffer, waiting until an object is
added if the buffer is empty. This method uses the default timeout
set in the constructor.
throws: BufferUnderflowException - if an interrupt is received |
remove | public Object remove(long timeout)(Code) | | Removes the next value from the buffer, waiting until an object is
added for up to the specified timeout value if the buffer is empty.
Parameters: timeout - the timeout value in milliseconds throws: BufferUnderflowException - if an interrupt is received throws: BufferUnderflowException - if the timeout expires since: Commons Collections 3.2 |
|
|