Package com.qfs.dic

Interface IConcurrentDictionary<K>

    • Field Detail

      • 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:
        Constant Field Values
    • Method Detail

      • 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
      • 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