crossbeam icon indicating copy to clipboard operation
crossbeam copied to clipboard

Document the semantics of SkipMap::compare_insert

Open blinsay opened this issue 1 year ago • 2 comments

I was trying to figure out from the documentation if SkipMap::compare_insert is atomic and didn't see anything explicitly mentioned. Based on a toy program that tries to use a SkipMap<&str, u64> as a set of atomic counters, it seems like it probably has the same semantics to get_or_insert_with and allows two concurrent callers to race. It'd be nice to reproduce that note on compare_insert (and maybe also get_or_insert) as well.

Happy to attach my toy program if it's useful. Thank you!

blinsay avatar Jul 01 '24 18:07 blinsay

SkipMap is the lock-free skip list, so it naturally allows two callers to race. It is atomic when actually replacing data(after I fixed it #1101), using compare_exchange. I will update the document. The implementation of compare_insert was done before I fixed the concurrency issues, which has led to some inaccuracies in the current documentation.

Tianion avatar Jul 12 '24 02:07 Tianion

Thank you!

blinsay avatar Jul 12 '24 17:07 blinsay