org.apache.myfaces.buildtools.maven2.plugin.javascript.uixtools
Class Queue

java.lang.Object
  extended by org.apache.myfaces.buildtools.maven2.plugin.javascript.uixtools.Queue
Direct Known Subclasses:
TokenBuffer

public class Queue
extends Object

Implements a first-in-first-out (FIFO) queue. Typically, one thread will add elements to this queue, and another will remove elements from this queue. This class is thread safe.

Version:
$Name: $ ($Revision: 606225 $) $Date: 2007-12-21 16:55:00 +0100 (Fri, 21 Dec 2007) $

Constructor Summary
Queue(int size)
           
 
Method Summary
 void add(Object obj)
          This method blocks until space is available in this queue.
 void close()
          closes this queue.
 boolean isClosed()
           
 boolean isEmpty()
           
 boolean isFull()
           
 Object remove()
          This method blocks until some element is added to this queue, or the queue is closed.
 int remove(List collector, int count)
          Removes multiple elements.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue(int size)
Parameters:
size - the maximum size of this queue
Method Detail

size

public final int size()
Returns:
the number of elements in this queue. This will never be larger than the maximum size of this queue.

isClosed

public final boolean isClosed()
Returns:
true if the queue has been closed.
See Also:
close()

close

public void close()
closes this queue. Any consequent add(Object) method calls will fail. All #get() operations will succeed until the queue is empty. This method may be called multiple times.

See Also:
isClosed()

isFull

public final boolean isFull()
Returns:
true if the queue is full and a call to add(Object) would block.

isEmpty

public final boolean isEmpty()
Returns:
true if the queue is empty and a call to #get() would block.

add

public void add(Object obj)
         throws InterruptedException,
                IllegalStateException
This method blocks until space is available in this queue.

Parameters:
obj - the Object to add to the end of this queue. null is permitted.
Throws:
InterruptedException - if the current thread is interrupted.
IllegalStateException - if queue is closed.
See Also:
close(), remove()

remove

public Object remove()
              throws InterruptedException,
                     IllegalStateException
This method blocks until some element is added to this queue, or the queue is closed.

Returns:
removes and returns the Object at the front of this queue. null may be returned if null was added using add(Object)
Throws:
InterruptedException - if the current thread is interrupted.
IllegalStateException - if queue is closed.
See Also:
close(), add(Object), #remove(LIst,int)

remove

public int remove(List collector,
                  int count)
           throws InterruptedException,
                  IllegalStateException
Removes multiple elements. This method will block until there is something to remove.

Parameters:
collector - all the elements removed from this queue are added to the end of this List.
count - the maximum number of elements to remove. If this is zero, then it defaults to the maximum size of this queue.
Returns:
the number of elements actually removed.
Throws:
InterruptedException
IllegalStateException
See Also:
remove()


Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.