mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-30 20:45:52 +00:00
797 B
797 B
Simplex.Messaging.TMap
STM-safe concurrent map (
TVar (Map k a)).
Source: TMap.hs
lookupInsert / lookupDelete
Atomic swap operations using stateTVar + alterF. lookupInsert returns the previous value (if any) while inserting the new one; lookupDelete returns the value while removing it. Both are single STM operations — no window between lookup and modification.
union
Left-biased: the passed-in Map wins on key conflicts. union additions tmap overwrites existing keys in tmap with values from additions.
alterF
The STM action f runs inside the same STM transaction. If f retries, the entire alterF retries. If f has side effects via other TVars, they compose atomically with the map modification.