Thread-safe data structures with Data.Map operations

Viewed 85

I'm looking for thread-safe data structures that have an interface similar to Data.Map, i.e., support fast insert, lookup, delete operations. By "thread-safe" I mean that these operations are atomic/linearizable. I know that I could simply use

data MyThreadSafeDS k a = MyThreadSafeDS (TVar (Map k a))

but benchmarks show that this performs very poorly when multiple threads are trying to do insertions/deletions concurrently. Interestingly, using an MVar gives worse results in this context.

Background: I've written a concurrent hash table and I'm looking for other thread-safe data structures to include in my benchmark results. I'm aware of hashtables, which doesn't seem to be thread-safe.

0 Answers
Related