org.mentaqueue
Class BrokenFastQueue<E>

java.lang.Object
  extended by org.mentaqueue.BrokenFastQueue<E>
All Implemented Interfaces:
BatchingQueue<E>

public class BrokenFastQueue<E>
extends Object
implements BatchingQueue<E>


Constructor Summary
BrokenFastQueue(Builder<E> builder)
           
BrokenFastQueue(Class<E> klass)
           
 
Method Summary
 long availableToPoll()
          Return the number of objects that can be safely polled from this queue.
 void donePolling()
          Called to indicate that all polling have been concluded.
 void donePolling(boolean lazySet)
          Called to indicate that all polling have been concluded.
 void flush()
          Dispatch *immediately* all previously obtained objects through the nextToDispatch() method to the queue.
 void flush(boolean lazySet)
          Dispatch all previously obtained objects through the nextToDispatch() method to the queue.
 E nextToDispatch()
          Return the next pooled mutable object that can be used by the producer to dispatch data to the queue.
 E poll()
          Poll a object from the queue.
 void rollback()
          Pretend you never polled the last object you polled since the last time you called donePolling().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokenFastQueue

public BrokenFastQueue(Builder<E> builder)

BrokenFastQueue

public BrokenFastQueue(Class<E> klass)
Method Detail

nextToDispatch

public final E nextToDispatch()
Description copied from interface: BatchingQueue
Return the next pooled mutable object that can be used by the producer to dispatch data to the queue.

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

flush

public final void flush(boolean lazySet)
Description copied from interface: BatchingQueue
Dispatch all previously obtained objects through the nextToDispatch() method to the queue.

Specified by:
flush in interface BatchingQueue<E>
Parameters:
lazySet - flush (i.e. notify the consumer) in a lazy way or flush immediately

flush

public final void flush()
Description copied from interface: BatchingQueue
Dispatch *immediately* all previously obtained objects through the nextToDispatch() method to the queue.

Specified by:
flush in interface BatchingQueue<E>

availableToPoll

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

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

poll

public final E poll()
Description copied from interface: BatchingQueue
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 BatchingQueue<E>
Returns:
an object from the queue.

donePolling

public final void donePolling(boolean lazySet)
Description copied from interface: BatchingQueue
Called to indicate that all polling have been concluded.

Specified by:
donePolling in interface BatchingQueue<E>
Parameters:
lazySet - notify the producer in a lazy way or notify the producer immediately

donePolling

public final void donePolling()
Description copied from interface: BatchingQueue
Called to indicate that all polling have been concluded.

Specified by:
donePolling in interface BatchingQueue<E>

rollback

public final void rollback()
Description copied from interface: BatchingQueue
Pretend you never polled the last object you polled since the last time you called donePolling(). You can call this as many times as you want before you call donePolling() and rollback any poll() you have done. This is unaffected by availableToPoll(). Only donePolling() reset the counter of the last polled objects. Because rollback() reset the counter of the last polled objects, you can even call it twice in a row and the second rollbac() will have no effect since you have polled anything.

Specified by:
rollback in interface BatchingQueue<E>


Copyright © 2012. All Rights Reserved.