org.norther.tammi.acorn.util.concurrent
Class NonBlockingQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue
          extended by org.norther.tammi.acorn.util.concurrent.NonBlockingQueue
All Implemented Interfaces:
Serializable, Iterable, Collection, BlockingQueue, Queue

public class NonBlockingQueue
extends AbstractQueue
implements BlockingQueue, Serializable

An array-based none-blocking queue class without any concurrency control. All methods are synchronized and those that should block throw IllegalStateException instead.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
NonBlockingQueue(int capacity)
          Creates a queue with the specified capacity.
 
Method Summary
 int capacity()
          Returns the capacity of the buffer.
 int drainTo(Collection c)
           
 int drainTo(Collection c, int max)
           
 Iterator iterator()
           
 boolean offer(Object o)
           
 boolean offer(Object o, long timeout, TimeUnit unit)
           
 Object peek()
           
 Object poll()
           
 Object poll(long timeout, TimeUnit unit)
           
 void put(Object o)
           
 int remainingCapacity()
           
 int size()
           
 Object take()
           
 
Methods inherited from class java.util.AbstractQueue
add, addAll, clear, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

NonBlockingQueue

public NonBlockingQueue(int capacity)
Creates a queue with the specified capacity.

Parameters:
capacity - the capacity.
Method Detail

offer

public boolean offer(Object o)
Specified by:
offer in interface BlockingQueue
Specified by:
offer in interface Queue

offer

public boolean offer(Object o,
                     long timeout,
                     TimeUnit unit)
Specified by:
offer in interface BlockingQueue

peek

public Object peek()
Specified by:
peek in interface Queue

poll

public Object poll()
Specified by:
poll in interface Queue

poll

public Object poll(long timeout,
                   TimeUnit unit)
Specified by:
poll in interface BlockingQueue

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in class AbstractCollection

drainTo

public int drainTo(Collection c)
Specified by:
drainTo in interface BlockingQueue

drainTo

public int drainTo(Collection c,
                   int max)
Specified by:
drainTo in interface BlockingQueue

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface BlockingQueue

put

public void put(Object o)
         throws InterruptedException
Specified by:
put in interface BlockingQueue
Throws:
InterruptedException

take

public Object take()
            throws InterruptedException
Specified by:
take in interface BlockingQueue
Throws:
InterruptedException

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in class AbstractCollection

capacity

public int capacity()
Returns the capacity of the buffer.

Returns:
the capacity.


Copyright © 2004 The Norther Organization. All rights reserved.