SynchRef.java
01 package org.apache.qpid.util.concurrent;
02 /*
03  
04  * Licensed to the Apache Software Foundation (ASF) under one
05  * or more contributor license agreements.  See the NOTICE file
06  * distributed with this work for additional information
07  * regarding copyright ownership.  The ASF licenses this file
08  * to you under the Apache License, Version 2.0 (the
09  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  
21  */
22 
23 
24 /**
25  * A SynchRef is an interface which is returned from the synchronous take and drain methods of {@link BatchSynchQueue},
26  * allowing call-backs to be made against the synchronizing strucutre. It allows the consumer to communicate when it
27  * wants producers that have their data taken to be unblocked.
28  *
29  <p/><table id="crc"><caption>CRC Card</caption>
30  <tr><th> Responsibilities
31  <tr><td> Report number of records returned by a taking operation.
32  <tr><td> Provide call-back to release producers of taken records.
33  </table>
34  */
35 public interface SynchRef
36 {
37     /**
38      * Reports the number of records taken by the take or drain operation.
39      *
40      @return The number of records taken by the take or drain operation.
41      */
42     public int getNumRecords();
43 
44     /**
45      * Any producers that have had their data elements taken from the queue but have not been unblocked are
46      * unblocked when this method is called. The exception to this is producers that have had their data put back
47      * onto the queue by a consumer. Producers that have had exceptions for their data items registered by consumers
48      * will be unblocked but will not return from their put call normally, but with an exception instead.
49      */
50     public void unblockProducers();
51 }