org.mentaqueue
Class BlockingQueue<E>

java.lang.Object
  extended by org.mentaqueue.BlockingQueue<E>
All Implemented Interfaces:
Queue<E>

public class BlockingQueue<E>
extends Object
implements Queue<E>


Constructor Summary
BlockingQueue(Builder<E> builder)
           
BlockingQueue(Class<E> klass)
           
BlockingQueue(int capacity, Builder<E> builder)
           
BlockingQueue(int capacity, Class<E> klass)
           
 
Method Summary
 long available()
          Return the number of objects that can be safely polled from this queue.
 void done()
          Called to indicate that all polling have been done.
 E nextToOffer()
          Return the next pooled mutable object that can be used by the producer.
 void offer(E e)
          Offer an object to the queue.
 E poll()
          Poll a object from the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingQueue

public BlockingQueue(int capacity,
                     Builder<E> builder)

BlockingQueue

public BlockingQueue(Builder<E> builder)

BlockingQueue

public BlockingQueue(Class<E> klass)

BlockingQueue

public BlockingQueue(int capacity,
                     Class<E> klass)
Method Detail

nextToOffer

public E nextToOffer()
Description copied from interface: Queue
Return the next pooled mutable object that can be used by the producer.

Specified by:
nextToOffer in interface Queue<E>
Returns:
the next mutable object that can be used by the producer.

offer

public void offer(E e)
Description copied from interface: Queue
Offer an object to the queue. The object must have been previously obtained by calling nextToOffer().

Specified by:
offer in interface Queue<E>
Parameters:
e - the object to be offered to the queue.

available

public long available()
Description copied from interface: Queue
Return the number of objects that can be safely polled from this queue. It can return zero.

Specified by:
available in interface Queue<E>
Returns:
number of objects that can be polled.

poll

public E poll()
Description copied from interface: Queue
Poll a object from the queue. You can only call this method after calling available() so you know what is the maximum times you can call it. NOTE: You should NOT keep your own reference for this mutable object. Read what you need to get from it and release its reference.

Specified by:
poll in interface Queue<E>
Returns:
an object from the queue.

done

public void done()
Description copied from interface: Queue
Called to indicate that all polling have been done.

Specified by:
done in interface Queue<E>


Copyright © 2012. All Rights Reserved.