Platforms to show: All Mac Windows Linux Cross-Platform
AtomicDictionaryMBS class New in 26.3
| Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
| class | Atomic | MBS Util Plugin | 26.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
This is a layer on top of a Xojo Dictionary to make it thread safe.
Please use special methods to get/compare/increment and set to benefit most of the thread safety. This avoids some other thread to make modifications between you query a value and putting in the new value.
A thread-safe dictionary is useful when multiple threads may read and write the same dictionary at the same time and you need to avoid
- data corruption
- race conditions
- inconsistent reads
- crashes/exceptions from concurrent modification
- object cache
- session tokens
- producer/consumer pattern
- store data for games where network, rendering, AI and physics threads access it
- event subscriber lists
- shared preferences
- only one thread accesses it
- access is already protected by a mutex
- immutable data is used
- the threads are cooperative
- 3 properties
- 19 methods
- method Clear
- method CompareAndSet(key As Variant, expectedValue as Variant, newValue as Variant) as Boolean
- method Constructor(Clone as AtomicDictionaryMBS)
- method Constructor(values as Dictionary = nil)
- method ExecuteLocked(theDelegate as DictionaryActionMBS)
- method GetAndSet(key As Variant, newValue as Variant, defaultValue as Variant = nil) as Variant
- method GetOrSet(key As Variant, defaultValue as Variant = nil) as Variant
- method HasKey(key As Variant) As Boolean
- method Increment(key As Variant, Value as Integer = 1) as Integer
- method Iterator as Iterator
- method Key(Index as Integer) as Variant
- method Keys as Variant()
- method Lookup(key As Variant, defaultValue As Variant = nil) As Variant
- method Remove(key As Variant)
- method RemoveAll
- method SetIfAbsent(key As Variant, Value as Variant) as Boolean
- method Value(key As Variant) As Variant
- method Value(key As Variant, Assigns value As Variant)
- method Values as Variant()
- delegate DictionaryActionMBS(dic As AtomicDictionaryMBS)
This class has no sub classes.
Interfaces:
1 interfaces.
Release notes
- Version 26.3
- Added AtomicDictionaryMBS class.
The items on this page are in the following plugins: MBS Util Plugin.
AtomicDictionaryIteratorMBS - AtomicFlagMBS