Package com.qfs.dic

Interface IConcurrentDictionary<K>

Type Parameters:
K - type of the indexed objects
All Superinterfaces:
ICompressible, IDictionary<K>, IMemoryMonitored, IWritableDictionary<K>, Serializable
All Known Implementing Classes:
AChristmasDictionary, AChristmasDictionaryArray, AChristmasDictionaryArray.ChristmasDictionaryDoubleArray, AChristmasDictionaryArray.ChristmasDictionaryFloatArray, AChristmasDictionaryArray.ChristmasDictionaryIntegerArray, AChristmasDictionaryArray.ChristmasDictionaryLongArray, AChristmasDictionaryArray.ChristmasDictionaryObjectArray, ChristmasDictionary, ChristmasDictionary.ChristmasDictionaryString, ChristmasDictionaryDouble, ChristmasDictionaryFloat, ChristmasDictionaryInteger, ChristmasDictionaryLong, SharedDelegateDictionary

public interface IConcurrentDictionary<K> extends IWritableDictionary<K>
An IDictionary that supports multiple concurrent writers and readers without any needs for outside synchronization.
Author:
ActiveViam
  • Field Details

    • NEW_MAPPING

      static final long NEW_MAPPING
      Marks the fact that the returned address is a new address (i.e. this was a new mapping).
      See Also:
  • Method Details

    • supportConcurrentReads

      default boolean supportConcurrentReads()
      Description copied from interface: IDictionary
      Returns whether the dictionary supports Single Writer/Multiple Reader (SWMR).
      Specified by:
      supportConcurrentReads in interface IDictionary<K>
      Returns:
      true if the dictionary supports SWMR, false otherwise
    • supportConcurrentWrites

      default boolean supportConcurrentWrites()
      Description copied from interface: IWritableDictionary
      Returns whether the dictionary supports concurrent writing (Multiple Writer/Multiple Reader) or not.
      Specified by:
      supportConcurrentWrites in interface IWritableDictionary<K>
      Returns:
      true if the dictionary supports concurrent writing, false otherwise
      See Also:
    • map

      long map(K key, IConcurrentDictionary.IDictionaryAction<K> mappingAction, IConcurrentDictionary.IDictionaryAction<K> existingKeyAction)
      Maps a new object in the dictionary the same way as IWritableDictionary.map(Object).

      If a new mapping is created because of this call (i.e. the key did not already exist in the dictionary), the associated mapping function is invoked before the mapping is made visible to the other threads. It will only become visible after the callback has returned.
      Other calls to IWritableDictionary.map(Object) should block until this new mapping is made visible and return the newly mapped position afterwards. Other calls to IDictionary.getPosition(K) might either block or return -1 if the new mapping is not visible yet.

      If a mapping already existed for this key, the existing key action is invoked before returning.

      The returned value is a long whose lower 4 bytes represent the mapped object's position, while its upper 4 bytes are used for various flags. The returned value can therefore simply be casted as an int to get the key's address.

      Parameters:
      key - the object to map in this dictionary
      mappingAction - the action to execute if a new mapping is created for this object, can be null
      existingKeyAction - the action to execute if a mapping already existed for this key, can be null
      Returns:
      a long that packs the key's dictionary address in its lower 4 bytes and various flags in the remaining upper 4 bytes