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
IDictionary that supports multiple concurrent writers and readers without any needs
for outside synchronization.- Author:
- ActiveViam
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA Single-Abstract-Method interface used to provide a callback in response to a dictionary action.Nested classes/interfaces inherited from interface com.qfs.dic.IWritableDictionary
IWritableDictionary.IDoubleDictionary, IWritableDictionary.IFloatDictionary, IWritableDictionary.IIntegerDictionary, IWritableDictionary.ILongDictionary -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longMarks the fact that the returned address is a new address (i.e.Fields inherited from interface com.qfs.dic.IDictionary
DEFAULT_INITIAL_CAPACITY, ID_GENERATOR -
Method Summary
Modifier and TypeMethodDescriptionlongmap(K key, IConcurrentDictionary.IDictionaryAction<K> mappingAction, IConcurrentDictionary.IDictionaryAction<K> existingKeyAction) Maps a new object in the dictionary the same way asIWritableDictionary.map(Object).default booleanReturns whether the dictionary supports Single Writer/Multiple Reader (SWMR).default booleanReturns whether the dictionary supports concurrent writing (Multiple Writer/Multiple Reader) or not.Methods inherited from interface com.qfs.memory.ICompressible
compress, compressMethods inherited from interface com.qfs.dic.IDictionary
copyInto, getDictionaryId, getDoublePosition, getFirstElements, getFloatPosition, getIntPosition, getLongPosition, getOrder, getPosition, getSize, getType, isNullable, read, readDouble, readFloat, readInt, readLong, sizeMethods inherited from interface com.qfs.monitoring.memory.IMemoryMonitored
getMemoryStatisticMethods inherited from interface com.qfs.dic.IWritableDictionary
clear, destroy, map, mapDouble, mapFloat, mapFromCell, mapInt, mapLong
-
Field Details
-
NEW_MAPPING
static final long NEW_MAPPINGMarks 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:IDictionaryReturns whether the dictionary supports Single Writer/Multiple Reader (SWMR).- Specified by:
supportConcurrentReadsin interfaceIDictionary<K>- Returns:
trueif the dictionary supports SWMR,falseotherwise
-
supportConcurrentWrites
default boolean supportConcurrentWrites()Description copied from interface:IWritableDictionaryReturns whether the dictionary supports concurrent writing (Multiple Writer/Multiple Reader) or not.- Specified by:
supportConcurrentWritesin interfaceIWritableDictionary<K>- Returns:
trueif the dictionary supports concurrent writing,falseotherwise- 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 asIWritableDictionary.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 toIWritableDictionary.map(Object)should block until this new mapping is made visible and return the newly mapped position afterwards. Other calls toIDictionary.getPosition(K)might either block or return-1if 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
longwhose 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 anintto get the key's address.- Parameters:
key- the object to map in this dictionarymappingAction- the action to execute if a new mapping is created for this object, can benullexistingKeyAction- the action to execute if a mapping already existed for this key, can benull- Returns:
- a long that packs the key's dictionary address in its lower 4 bytes and various flags in the remaining upper 4 bytes
-