Interface BlockingMap<K,V>

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

public interface BlockingMap<K,V> extends Map<K,V>
  • Method Details

    • give

      boolean give(K key, V value)
      Adds an entry only if there's already a consumer waiting for the value.
      Parameters:
      key - key for the entry to be added
      value - entry to be added
      Returns:
      true if entry was added and a consumer is already waiting for the value, false otherwise
    • take

      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 - key for the entry
      Returns:
      the value of the entry
      Throws:
      InterruptedException
    • asyncTake

      Waits for an entry in a background thread.
      Parameters:
      key - key for the entry
      Returns:
      Future the result
    • 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 - key for the entry
      timeout - timeout before the methods returns
      unit - time unit used in conjunction with timout
      Returns:
      the value of the entry
      Throws:
      InterruptedException
    • asyncPoll

      Future<V> asyncPoll(K key, long timeout, TimeUnit unit)
      Polls for an entry in a background thread.
      Parameters:
      key - key for the entry
      Returns:
      Future the result