git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@333047 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2005-11-13 16:21:57 +00:00
parent de24039305
commit ea2548e01e
1 changed files with 28 additions and 0 deletions

View File

@ -89,6 +89,12 @@ public class BlockingBuffer extends SynchronizedBuffer {
} }
} }
/**
* Gets the next value from the buffer, waiting until an object is
* added if the buffer is empty.
*
* @throws BufferUnderflowException if an interrupt is received
*/
public Object get() { public Object get() {
synchronized (lock) { synchronized (lock) {
while (collection.isEmpty()) { while (collection.isEmpty()) {
@ -104,6 +110,14 @@ public class BlockingBuffer extends SynchronizedBuffer {
} }
} }
/**
* 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.
*
* @param timeout the timeout value in milliseconds
* @throws BufferUnderflowException if an interrupt is received
* @throws BufferUnderflowException if the timeout expires
*/
public Object get(final long timeout) { public Object get(final long timeout) {
synchronized (lock) { synchronized (lock) {
final long expiration = System.currentTimeMillis() + timeout; final long expiration = System.currentTimeMillis() + timeout;
@ -125,6 +139,12 @@ public class BlockingBuffer extends SynchronizedBuffer {
} }
} }
/**
* Removes the next value from the buffer, waiting until an object is
* added if the buffer is empty.
*
* @throws BufferUnderflowException if an interrupt is received
*/
public Object remove() { public Object remove() {
synchronized (lock) { synchronized (lock) {
while (collection.isEmpty()) { while (collection.isEmpty()) {
@ -140,6 +160,14 @@ public class BlockingBuffer extends SynchronizedBuffer {
} }
} }
/**
* 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.
*
* @param timeout the timeout value in milliseconds
* @throws BufferUnderflowException if an interrupt is received
* @throws BufferUnderflowException if the timeout expires
*/
public Object remove(final long timeout) { public Object remove(final long timeout) {
synchronized (lock) { synchronized (lock) {
final long expiration = System.currentTimeMillis() + timeout; final long expiration = System.currentTimeMillis() + timeout;