org.apache.qpid.util.concurrent
Class BatchSynchQueueBase.SynchRecordImpl<E>

java.lang.Object
  extended by org.apache.qpid.util.concurrent.BatchSynchQueueBase.SynchRecordImpl<E>
All Implemented Interfaces:
SynchRecord<E>
Enclosing class:
BatchSynchQueueBase<E>

public class BatchSynchQueueBase.SynchRecordImpl<E>
extends Object
implements SynchRecord<E>

A SynchRecordImpl is used by a BatchSynchQueue to pair together a producer with its data. This allows the producer of data to be identified so that it can be unblocked when its data is consumed or sent errors when its data cannot be consumed.


Field Summary
(package private)  E element
          The data element associated with this item.
(package private)  BooleanLatch latch
          A boolean latch that determines when the producer for this data item will be allowed to continue.
 
Constructor Summary
BatchSynchQueueBase.SynchRecordImpl(E e)
          Create a new synch record.
 
Method Summary
 E getElement()
          Gets the data element contained by this record.
 void inError(Exception e)
          Tells the synch queue to raise an exception with this elements producer.
 void releaseImmediately()
          Immediately releases the producer of this data record.
 void reQueue()
          Tells the synch queue to put this element back onto the queue instead of releasing its producer.
 void waitForConsumer()
          Waits until the producer is given permission to proceded by a consumer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

latch

BooleanLatch latch
A boolean latch that determines when the producer for this data item will be allowed to continue.


element

E element
The data element associated with this item.

Constructor Detail

BatchSynchQueueBase.SynchRecordImpl

public BatchSynchQueueBase.SynchRecordImpl(E e)
Create a new synch record.

Parameters:
e - The data element that the record encapsulates.
Method Detail

waitForConsumer

public void waitForConsumer()
Waits until the producer is given permission to proceded by a consumer.


getElement

public E getElement()
Gets the data element contained by this record.

Specified by:
getElement in interface SynchRecord<E>
Returns:
The data element contained by this record.

releaseImmediately

public void releaseImmediately()
Immediately releases the producer of this data record. Consumers can bring the synchronization time of producers to a minimum by using this method to release them at the earliest possible moment when batch consuming records from sychronized producers.

Specified by:
releaseImmediately in interface SynchRecord<E>

reQueue

public void reQueue()
Tells the synch queue to put this element back onto the queue instead of releasing its producer. The element is not requeued immediately but upon calling the SynchRef.unblockProducers() method or the releaseImmediately() method.

This method will raise a runtime exception AlreadyUnblockedException if the producer for this element has already been unblocked.

Specified by:
reQueue in interface SynchRecord<E>

inError

public void inError(Exception e)
Tells the synch queue to raise an exception with this elements producer. The exception is not raised immediately but upon calling the SynchRef.unblockProducers() method or the releaseImmediately() method. The exception will be wrapped in a SynchException before it is raised on the producer.

This method is unusual in that it accepts an exception as an argument. This is non-standard but is used because the exception is to be passed onto a different thread.

This method will raise a runtime exception AlreadyUnblockedException if the producer for this element has already been unblocked.

Specified by:
inError in interface SynchRecord<E>
Parameters:
e - The exception to raise on the producer.


Licensed to the Apache Software Foundation