Concurrent sorted map

Any recommendations for a concurrent sorted map in rust. I looked at Crossbeam SkipMap which is concurrent and sorted but I cannot get a mutable reference to values in it. I looked at DashMap and it is not sorted.

1 Like

Rust &mut references are guaranteed to be strictly exclusive (when you can use &mut, it's guaranteed there is no other usable &mut to the same data anywhere else in the program), so they can't ever be concurrent pretty much by definition.

Think of &mut not as mutability, but mutually exclusive.

If you need to mutate data inside the map, you will have to do it without &mut, e.g. via Mutex or Atomic* types.

1 Like

I think the best bet would be write a wrapper around crossbeam SkipMap using DashMap's locking strategy. But it seems no one has done it yet.