org.apache.qpid.util.concurrent
Class SynchBuffer<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by org.apache.qpid.util.concurrent.BatchSynchQueueBase<E>
              extended by org.apache.qpid.util.concurrent.SynchBuffer<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>, BatchSynchQueue<E>

public class SynchBuffer<E>
extends BatchSynchQueueBase<E>

SynchBuffer completes the BatchSynchQueueBase abstract class by providing an implementation of the underlying queue as an array. This uses FIFO ordering for the queue but restricts the maximum size of the queue to a fixed amount. It also has the advantage that, as the buffer does not grow and shrink dynamically, memory for the buffer is allocated up front and does not create garbage during the operation of the queue.

CRC Card
Responsibilities Collaborations
Provide array based FIFO queue to create a batch synched queue around.

Todo:
Write an array based buffer implementation that implements Queue.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.qpid.util.concurrent.BatchSynchQueueBase
BatchSynchQueueBase.SynchRecordImpl<E>, BatchSynchQueueBase.SynchRefImpl
 
Field Summary
 
Fields inherited from class org.apache.qpid.util.concurrent.BatchSynchQueueBase
buffer
 
Constructor Summary
SynchBuffer()
           
 
Method Summary
protected
<T> Queue<T>
createQueue()
          Returns an empty queue, implemented as an array.
 
Methods inherited from class org.apache.qpid.util.concurrent.BatchSynchQueueBase
drainTo, drainTo, drainTo, drainTo, extract, getBufferCapacity, insert, iterator, offer, offer, peek, peekAtBufferHead, poll, poll, put, remainingCapacity, size, take, tryPut
 
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, contains, remove
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SynchBuffer

public SynchBuffer()
Method Detail

createQueue

protected <T> Queue<T> createQueue()
Returns an empty queue, implemented as an array.

Specified by:
createQueue in class BatchSynchQueueBase<E>
Returns:
An empty queue, implemented as an array.


Licensed to the Apache Software Foundation