org.mortbay.util

Class BlockingQueue

public class BlockingQueue extends Object

Blocking queue. Implemented as circular buffer in a Vector. Synchronization is on the vector to avoid double synchronization.

Version: $Id: BlockingQueue.java,v 1.5 2004/05/09 20:32:49 gregwilkins Exp $

Author: Greg Wilkins (gregw)

Constructor Summary
BlockingQueue(int maxSize)
Constructor.
BlockingQueue(Object lock, int maxSize)
Constructor.
Method Summary
voidclear()
Objectget()
Get object from queue.
Objectget(int timeoutMs)
Get from queue.
intmaxSize()
Objectpeek()
Peek at the queue.
Objectpeek(int timeoutMs)
Peek at the queue.
voidput(Object o)
Put object in queue.
voidput(Object o, int timeout)
Put object in queue.
intsize()

Constructor Detail

BlockingQueue

public BlockingQueue(int maxSize)
Constructor.

BlockingQueue

public BlockingQueue(Object lock, int maxSize)
Constructor.

Method Detail

clear

public void clear()

get

public Object get()
Get object from queue. Block if there are no objects to get.

Returns: The next object in the queue.

get

public Object get(int timeoutMs)
Get from queue. Block for timeout if there are no objects to get.

Parameters: timeoutMs the time to wait for a job

Returns: The next object in the queue, or null if timedout.

maxSize

public int maxSize()

peek

public Object peek()
Peek at the queue. Block if there are no objects to peek.

Returns: The next object in the queue, or null if timedout.

peek

public Object peek(int timeoutMs)
Peek at the queue. Block for timeout if there are no objects to peek.

Parameters: timeoutMs the time to wait for a job

Returns: The next object in the queue, or null if timedout.

put

public void put(Object o)
Put object in queue.

Parameters: o Object

put

public void put(Object o, int timeout)
Put object in queue.

Parameters: timeout If timeout expires, throw InterruptedException o Object

Throws: InterruptedException Timeout expired or otherwise interrupted

size

public int size()
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.