Example #1
0
 /**
  * Returns a synchronized buffer backed by the given buffer that will
  * block on {@link Buffer#get()} and {@link Buffer#remove()} operations.
  * If the buffer is empty, then the {@link Buffer#get()} and
  * {@link Buffer#remove()} operations will block until new elements
  * are added to the buffer, rather than immediately throwing a
  * <code>BufferUnderflowException</code>.
  *
  * @param buffer  the buffer to synchronize, must not be null
  * @return a blocking buffer backed by that buffer
  * @throws IllegalArgumentException  if the Buffer is null
  */
 public static Buffer blockingBuffer(Buffer buffer)
 {
     return(BlockingBuffer.decorate(buffer));
 }
Example #2
0
 /**
  * Returns a synchronized buffer backed by the given buffer that will
  * block on {@link Buffer#get()} and {@link Buffer#remove()} operations
  * until <code>timeout</code> expires.  If the buffer is empty, then the
  * {@link Buffer#get()} and {@link Buffer#remove()} operations will block
  * until new elements are added to the buffer, rather than immediately
  * throwing a <code>BufferUnderflowException</code>.
  *
  * @param buffer  the buffer to synchronize, must not be null
  * @param timeoutMillis  the timeout value in milliseconds, zero or less for no timeout
  * @return a blocking buffer backed by that buffer
  * @throws IllegalArgumentException  if the Buffer is null
  * @since Commons Collections 3.2
  */
 public static Buffer blockingBuffer(Buffer buffer, long timeoutMillis)
 {
     return(BlockingBuffer.decorate(buffer, timeoutMillis));
 }