⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.buffer

Class BlockingBuffer

java.lang.Object
|
+--org.apache.commons.collections.collection.SynchronizedCollection
   |
   +--org.apache.commons.collections.buffer.SynchronizedBuffer
      |
      +--org.apache.commons.collections.buffer.BlockingBuffer


public class BlockingBuffer
extends SynchronizedBuffer

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.

Since:
Commons Collections 3.0
Authors:
Stephen Colebourne
Janek Bogucki
Phil Steitz

Constructor Summary

BlockingBuffer(Buffer buffer)

Constructor that wraps (not copies).

Method Summary

boolean

add(Object o)

boolean

addAll(Collection c)

static Buffer

decorate(Buffer buffer)

Factory method to create a blocking buffer.

Object

get()

Object

remove()

Constructor Details

BlockingBuffer

protected BlockingBuffer(Buffer buffer)

Constructor that wraps (not copies).

Parameters:
buffer - the buffer to decorate, must not be null
Throws:
- if the buffer is null

Method Details

add

public boolean add(Object o)

Parameters:
o

addAll

public boolean addAll(Collection c)

Parameters:
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
Throws:
- if buffer is null

get

public Object get()


remove

public Object remove()