Package mondrian.util

Class BlockingHashMap<K,​V>

  • Type Parameters:
    K - request (key) type
    V - 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 in SegmentCacheManager and MonitorImpl.

    Thread safety. BlockingHashMap is thread safe. The class delegates all get and put operations to a ConcurrentHashMap.

    • Constructor Detail

      • BlockingHashMap

        public BlockingHashMap​(int capacity)
        Creates a BlockingHashMap with given capacity.
        Parameters:
        capacity - Capacity
    • Method Detail

      • put

        public void put​(K k,
                        V v)
        Places a (request, response) pair onto the map.
        Parameters:
        k - key
        v - 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