Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the semantics of SkipMap::compare_insert #1122

Open
blinsay opened this issue Jul 1, 2024 · 2 comments
Open

Document the semantics of SkipMap::compare_insert #1122

blinsay opened this issue Jul 1, 2024 · 2 comments

Comments

@blinsay
Copy link

blinsay commented Jul 1, 2024

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!

@Tianion
Copy link
Contributor

Tianion commented Jul 12, 2024

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.

@blinsay
Copy link
Author

blinsay commented Jul 12, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants