Coverage Report - ca.uhn.hl7v2.concurrent.BlockingMap
 
Classes in this File Line Coverage Branch Coverage Complexity
BlockingMap
N/A
N/A
1
 
 1  
 package ca.uhn.hl7v2.concurrent;
 2  
 
 3  
 import java.util.Map;
 4  
 import java.util.concurrent.Future;
 5  
 import java.util.concurrent.TimeUnit;
 6  
 
 7  
 public interface BlockingMap<K, V> extends Map<K, V> {
 8  
 
 9  
         /**
 10  
          * Adds an entry only if there's already a consumer waiting for the value.
 11  
          * 
 12  
          * @param key key for the entry to be added
 13  
          * @param value entry to be added
 14  
          * @return true if entry was added and a consumer is already waiting for the
 15  
          *         value, false otherwise
 16  
          */
 17  
         boolean give(K key, V value);
 18  
 
 19  
         /**
 20  
          * Waits for an entry for the given key and returns the associated value.
 21  
          * May return null if the producer withdraws the entry without providing a
 22  
          * value.
 23  
          * 
 24  
          * @param key key for the entry
 25  
          * @return the value of the entry
 26  
          * @throws InterruptedException
 27  
          */
 28  
         V take(K key) throws InterruptedException;
 29  
         
 30  
         /**
 31  
          * Waits for an entry in a background thread.
 32  
          * 
 33  
          * @param key key for the entry
 34  
          * @return Future the result
 35  
          * @throws InterruptedException
 36  
          */
 37  
         Future<V> asyncTake(K key) throws InterruptedException;
 38  
 
 39  
         /**
 40  
          * Waits for the specified amount of time for an entry with the given key
 41  
          * and returns the associated value. Returns null if no value was provided
 42  
          * within the poll time. May return null if the producer withdraws the entry
 43  
          * without providing a value.
 44  
          * 
 45  
          * @param key key for the entry
 46  
          * @param timeout timeout before the methods returns
 47  
          * @param unit time unit used in conjunction with timout
 48  
          * @return the value of the entry
 49  
          * @throws InterruptedException
 50  
          */
 51  
         V poll(K key, long timeout, TimeUnit unit) throws InterruptedException;
 52  
 
 53  
         /**
 54  
          * Polls for an entry in a background thread.
 55  
          * 
 56  
          * @param key key for the entry
 57  
          * @return Future the result
 58  
          * @throws InterruptedException
 59  
          */
 60  
         Future<V> asyncPoll(K key, long timeout, TimeUnit unit) throws InterruptedException;
 61  
 }
 62