|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.collection.SynchronizedCollection
org.apache.commons.collections.buffer.SynchronizedBuffer
org.apache.commons.collections.buffer.BlockingBuffer
public class BlockingBuffer
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. This class contains an extra field in 3.2, however the serialization specification will handle this gracefully.
| Field Summary |
|---|
| Fields inherited from class org.apache.commons.collections.collection.SynchronizedCollection |
|---|
collection, lock |
| Constructor Summary | |
|---|---|
protected |
BlockingBuffer(Buffer buffer)
Constructor that wraps (not copies). |
protected |
BlockingBuffer(Buffer buffer,
long timeoutMillis)
Constructor that wraps (not copies). |
| Method Summary | |
|---|---|
boolean |
add(java.lang.Object o)
|
boolean |
addAll(java.util.Collection c)
|
static Buffer |
decorate(Buffer buffer)
Factory method to create a blocking buffer. |
static Buffer |
decorate(Buffer buffer,
long timeoutMillis)
Factory method to create a blocking buffer with a timeout value. |
java.lang.Object |
get()
Gets the next value from the buffer, waiting until an object is added if the buffer is empty. |
java.lang.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. |
java.lang.Object |
remove()
Removes the next value from the buffer, waiting until an object is added if the buffer is empty. |
java.lang.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. |
| 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 buffer)
buffer - the buffer to decorate, must not be null
java.lang.IllegalArgumentException - if the buffer is null
protected BlockingBuffer(Buffer buffer,
long timeoutMillis)
buffer - the buffer to decorate, must not be nulltimeoutMillis - the timeout value in milliseconds, zero or less for no timeout
java.lang.IllegalArgumentException - if the buffer is null| Method Detail |
|---|
public static Buffer decorate(Buffer buffer)
buffer - the buffer to decorate, must not be null
java.lang.IllegalArgumentException - if buffer is null
public static Buffer decorate(Buffer buffer,
long timeoutMillis)
buffer - the buffer to decorate, must not be nulltimeoutMillis - the timeout value in milliseconds, zero or less for no timeout
java.lang.IllegalArgumentException - if the buffer is nullpublic boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in class SynchronizedCollectionpublic boolean addAll(java.util.Collection c)
addAll in interface java.util.CollectionaddAll in class SynchronizedCollectionpublic java.lang.Object get()
get in interface Bufferget in class SynchronizedBufferBufferUnderflowException - if an interrupt is receivedpublic java.lang.Object get(long timeout)
timeout - the timeout value in milliseconds
BufferUnderflowException - if an interrupt is received
BufferUnderflowException - if the timeout expirespublic java.lang.Object remove()
remove in interface Bufferremove in class SynchronizedBufferBufferUnderflowException - if an interrupt is receivedpublic java.lang.Object remove(long timeout)
timeout - the timeout value in milliseconds
BufferUnderflowException - if an interrupt is received
BufferUnderflowException - if the timeout expires
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||