ca.uhn.hl7v2.concurrent
Interface BlockingMap<K,V>

All Superinterfaces:
Map<K,V>
All Known Implementing Classes:
BlockingHashMap

public interface BlockingMap<K,V>
extends Map<K,V>


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 Future<V> asyncPoll(K key, long timeout, TimeUnit unit)
          Polls for an entry in a background thread.
 Future<V> asyncTake(K key)
          Waits for an entry in a background thread.
 boolean give(K key, V value)
          Adds an entry only if there's already a consumer waiting for the value.
 V poll(K key, long timeout, TimeUnit unit)
          Waits for the specified amount of time for an entry with the given key and returns the associated value.
 V take(K key)
          Waits for an entry for the given key and returns the associated value.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

give

boolean give(K key,
             V value)
Adds an entry only if there's already a consumer waiting for the value.

Parameters:
key -
value -
Returns:
true if entry was added and a consumer is already waiting for the value, false otherwise

take

V take(K key)
       throws InterruptedException
Waits for an entry for the given key and returns the associated value. May return null if the producer withdraws the entry without providing a value.

Parameters:
key -
Returns:
the value of the entry
Throws:
InterruptedException

asyncTake

Future<V> asyncTake(K key)
                    throws InterruptedException
Waits for an entry in a background thread.

Parameters:
key -
Returns:
Future the result
Throws:
InterruptedException

poll

V poll(K key,
       long timeout,
       TimeUnit unit)
       throws InterruptedException
Waits for the specified amount of time for an entry with the given key and returns the associated value. Returns null if no value was provided within the poll time. May return null if the producer withdraws the entry without providing a value.

Parameters:
key -
timeout -
unit -
Returns:
Throws:
InterruptedException

asyncPoll

Future<V> asyncPoll(K key,
                    long timeout,
                    TimeUnit unit)
                    throws InterruptedException
Polls for an entry in a background thread.

Parameters:
key -
Returns:
Future the result
Throws:
InterruptedException


Copyright © 2001-2012 University Health Network. All Rights Reserved.