Class BlockingBuffer
- java.lang.Object
 - 
- org.apache.commons.collections.collection.SynchronizedCollection
 - 
- org.apache.commons.collections.buffer.SynchronizedBuffer
 - 
- org.apache.commons.collections.buffer.BlockingBuffer
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Iterable,java.util.Collection,Buffer
@Deprecated(since="2021-04-30") public class BlockingBuffer extends SynchronizedBuffer
Deprecated.Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.Decorates anotherBufferto makeget()andremove()block when theBufferis empty.If either
getorremoveis called on an emptyBuffer, the calling thread waits for notification that anaddoraddAlloperation has completed.When one or more entries are added to an empty
Buffer, all threads blocked ingetorremoveare notified. There is no guarantee that concurrent blockedgetorremoverequests 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.
- Since:
 - Commons Collections 3.0
 - See Also:
 - Serialized Form
 
 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(java.lang.Object o)Deprecated.booleanaddAll(java.util.Collection c)Deprecated.static Bufferdecorate(Buffer buffer)Deprecated.Factory method to create a blocking buffer.static Bufferdecorate(Buffer buffer, long timeoutMillis)Deprecated.Factory method to create a blocking buffer with a timeout value.java.lang.Objectget()Deprecated.Gets the next value from the buffer, waiting until an object is added if the buffer is empty.java.lang.Objectget(long timeout)Deprecated.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.Objectremove()Deprecated.Removes the next value from the buffer, waiting until an object is added if the buffer is empty.java.lang.Objectremove(long timeout)Deprecated.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.collection.SynchronizedCollection
clear, contains, containsAll, decorate, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString 
 - 
 
 - 
 
- 
- 
Method Detail
- 
decorate
public static Buffer decorate(Buffer buffer)
Deprecated.Factory method to create a blocking buffer.- Parameters:
 buffer- the buffer to decorate, must not be null- Returns:
 - a new blocking Buffer
 - Throws:
 java.lang.IllegalArgumentException- if buffer is null
 
- 
decorate
public static Buffer decorate(Buffer buffer, long timeoutMillis)
Deprecated.Factory method to create a blocking buffer with a timeout value.- Parameters:
 buffer- the buffer to decorate, must not be nulltimeoutMillis- the timeout value in milliseconds, zero or less for no timeout- Returns:
 - a new blocking buffer
 - Throws:
 java.lang.IllegalArgumentException- if the buffer is null- Since:
 - Commons Collections 3.2
 
 
- 
add
public boolean add(java.lang.Object o)
Deprecated.- Specified by:
 addin interfacejava.util.Collection- Overrides:
 addin classSynchronizedCollection
 
- 
addAll
public boolean addAll(java.util.Collection c)
Deprecated.- Specified by:
 addAllin interfacejava.util.Collection- Overrides:
 addAllin classSynchronizedCollection
 
- 
get
public java.lang.Object get()
Deprecated.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.- Specified by:
 getin interfaceBuffer- Overrides:
 getin classSynchronizedBuffer- Returns:
 - the next object in the buffer, which is not removed
 - Throws:
 BufferUnderflowException- if an interrupt is received
 
- 
get
public java.lang.Object get(long timeout)
Deprecated.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 receivedBufferUnderflowException- if the timeout expires- Since:
 - Commons Collections 3.2
 
 
- 
remove
public java.lang.Object remove()
Deprecated.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.- Specified by:
 removein interfaceBuffer- Overrides:
 removein classSynchronizedBuffer- Returns:
 - the next object in the buffer, which is also removed
 - Throws:
 BufferUnderflowException- if an interrupt is received
 
- 
remove
public java.lang.Object remove(long timeout)
Deprecated.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 receivedBufferUnderflowException- if the timeout expires- Since:
 - Commons Collections 3.2
 
 
 - 
 
 -