Package mondrian.util
Class BlockingHashMap<K,V>
- java.lang.Object
-
- mondrian.util.BlockingHashMap<K,V>
-
- Type Parameters:
K
- request (key) typeV
- response (value) type
public class BlockingHashMap<K,V> extends Object
A limited Map implementation which supports waiting for a value to be available when calling get(). Intended for use with producer/consumer queues, where a producer thread puts a value into the collection with a separate thread waiting to get that value. Currently used by the Actor implementations inSegmentCacheManager
andMonitorImpl
.Thread safety. BlockingHashMap is thread safe. The class delegates all get and put operations to a ConcurrentHashMap.
-
-
Constructor Summary
Constructors Constructor Description BlockingHashMap(int capacity)
Creates a BlockingHashMap with given capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
get(K k)
Retrieves the response from the map matching the given key, blocking until it is received.void
put(K k, V v)
Places a (request, response) pair onto the map.
-
-
-
Method Detail
-
put
public void put(K k, V v)
Places a (request, response) pair onto the map.- Parameters:
k
- keyv
- value
-
get
public V get(K k) throws InterruptedException
Retrieves the response from the map matching the given key, blocking until it is received.- Parameters:
k
- key- Returns:
- value
- Throws:
InterruptedException
- if interrupted while waiting
-
-