blob: 5e002100c24ac2ab1da4e7d621cff466d07caafc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package org.apache.qpid.util.concurrent;
/**
* SynchRecord associates a data item from a {@link BatchSynchQueue} with its producer. This enables the data item data
* item to be put back on the queue without unblocking its producer, or to send exceptions to the producer.
*
* <p/><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
* <tr><td> Get the underlying data element.
* <tr><td> Put the data element back on the queue without unblocking its producer.
* <tr><td> Send and exception to the data elements producer.
* </table>
*/
public interface SynchRecord<E>
{
/**
* Gets the data element contained by this record.
*
* @return The data element contained by this record.
*/
public E getElement();
/**
* 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 {@link SynchRef#unblockProducers()} method.
*
* <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this element
* has already been unblocked.
*/
public void reQueue();
/**
* 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.
*/
public void releaseImmediately();
/**
* Tells the synch queue to raise an exception with this elements producer. The exception is not raised immediately
* but upon calling the {@link SynchRef#unblockProducers()} method. The exception will be wrapped in a
* {@link SynchException} before it is raised on the producer.
*
* <p/>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.
*
* <p/>This method will raise a runtime exception {@link AlreadyUnblockedException} if the producer for this element
* has already been unblocked.
*
* @param e The exception to raise on the producer.
*/
public void inError(Exception e);
}
|