Jadex 0.96-beta1

jadex.util.collection
Class ArrayBlockingQueue

java.lang.Object
  extended by jadex.util.collection.ArrayBlockingQueue
All Implemented Interfaces:
IBlockingQueue

public class ArrayBlockingQueue
extends Object
implements IBlockingQueue

Blocking queue implemented as array. The array is expanded automatically when the queue grows.


Nested Class Summary
 
Nested classes/interfaces inherited from interface jadex.util.collection.IBlockingQueue
IBlockingQueue.ClosedException, IBlockingQueue.TimeoutException
 
Constructor Summary
ArrayBlockingQueue()
          Create a new blocking queue.
 
Method Summary
 Object dequeue()
          Remove an object from the queue (blocks until an element is available).
 Object dequeue(long timeout)
          Dequeue an element.
 void enqueue(Object o)
          Add an element to the end of the queue.
 void setClosed(boolean closed)
          Close the queue.
 int size()
          Get the number of elements in the queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayBlockingQueue

public ArrayBlockingQueue()
Create a new blocking queue.

Method Detail

size

public int size()
Get the number of elements in the queue.

Specified by:
size in interface IBlockingQueue
Returns:
The size.

enqueue

public void enqueue(Object o)
Add an element to the end of the queue.

Specified by:
enqueue in interface IBlockingQueue
Parameters:
o - The element.

dequeue

public Object dequeue(long timeout)
               throws IBlockingQueue.ClosedException,
                      IBlockingQueue.TimeoutException
Dequeue an element.

Specified by:
dequeue in interface IBlockingQueue
Parameters:
timeout - the time to wait (in millis) or -1 for no timeout.
Returns:
The element. When queue is empty the methods blocks until an element is added or the timeout occurs.
Throws:
IBlockingQueue.ClosedException
IBlockingQueue.TimeoutException

dequeue

public Object dequeue()
Remove an object from the queue (blocks until an element is available).

Specified by:
dequeue in interface IBlockingQueue
Returns:
The element. When queue is empty the methods blocks until an element is added.

setClosed

public void setClosed(boolean closed)
Close the queue.

Specified by:
setClosed in interface IBlockingQueue
Parameters:
closed - The closed state.

Jadex 0.96-beta1

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2007 Lars Braubach, Alexander Pokahr - University of Hamburg. Use is subject to license terms.