Beside the multi-threaded issue, there's also the problem you'd have to write a procedure for each data type the Maps may have in your program.
Also, I believe to remember PB doesn't like to Push/Pop the Map and List Positions when there's no current element. You'd have to make a few additional checks which could also be a drain on efficiency, when done in "external" PureBasic code.
MapElementExists(Map(), Key$)
Re: MapElementExists(Map(), Key$)
You cannot safely access a Map from multiple threads as long as there is the possibility for updates. So you would still need a mutex even with this proposed command to protect against reading while an update is in progress.
If you have no updates then a local copy of the map for each thread might be the better option.
If you have no updates then a local copy of the map for each thread might be the better option.
quidquid Latine dictum sit altum videtur
Re: MapElementExists(Map(), Key$)
Maybe its time to look at an alternative to a map if it cant be practically made to be thread safe.
Squint3 provides
Lock free Reads and Writes.
Keys can be strings, numeric or binary.
Dynamically grows and shrinks
Operates in constant time O(k) speed is dependent on size of the key
Generally uses less memory than a map
key space is Lexographically sorted
Can use stored cursors for faster access (single writer only) so it can be used like an In memory DB
viewtopic.php?t=79453
Squint3 provides
Lock free Reads and Writes.
Keys can be strings, numeric or binary.
Dynamically grows and shrinks
Operates in constant time O(k) speed is dependent on size of the key
Generally uses less memory than a map
key space is Lexographically sorted
Can use stored cursors for faster access (single writer only) so it can be used like an In memory DB
viewtopic.php?t=79453