Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

All Implemented Interfaces:
  Buffer, Collection, Serializable

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.

This class is Serializable from Commons Collections 3.1.

Since:
  Commons Collections 3.0
Version:
  $Revision: 1.7 $ $Date: 2004/06/03 22:02:13 $
Author:
  Stephen Colebourne, Janek Bogucki, Phil Steitz
See Also:
  Serialized Form

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).

Method Summary
`boolean` | `add(Object o)`
`boolean` | `addAll(Collection c)`
`static Buffer` | `decorate(Buffer buffer)` Factory method to create a blocking buffer.
`Object` | `get()` Gets the next object from the buffer without removing it.
`Object` | `remove()` Gets and removes the next object from the buffer.

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

### BlockingBuffer

    protected BlockingBuffer(Buffer buffer)

  Constructor that wraps (not copies).

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

Method Detail

### decorate

    public static Buffer decorate(Buffer buffer)

  Factory method to create a blocking buffer.

  Parameters:
    `buffer` - the buffer to decorate, must not be null
  Returns:
    a new blocking Buffer
  Throws:
    `IllegalArgumentException` - if buffer is null

### add

    public boolean add(Object o)

  Specified by:
    `add` in interface `Collection`
  Overrides:
    `add` in class `SynchronizedCollection`

### addAll

    public boolean addAll(Collection c)

  Specified by:
    `addAll` in interface `Collection`
  Overrides:
    `addAll` in class `SynchronizedCollection`

### get

    public Object get()

  Description copied from interface: `Buffer`
  Gets the next object from the buffer without removing it.

  Specified by:
    `get` in interface `Buffer`
  Overrides:
    `get` in class `SynchronizedBuffer`
  Returns:
    the next object in the buffer, which is not removed

### remove

    public Object remove()

  Description copied from interface: `Buffer`
  Gets and removes the next object from the buffer.

  Specified by:
    `remove` in interface `Buffer`
  Overrides:
    `remove` in class `SynchronizedBuffer`
  Returns:
    the next object in the buffer, which is also removed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.