-
Notifications
You must be signed in to change notification settings - Fork 46
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
CompareAndStore would be nice #18
Comments
Yes this is useful, will add it in the next release 👍 |
Also variants like LoadOrCalculate would be pretty awesome (same behaviour as LoadOrStore, but you give it a function that returns the value to store, for complex or costly generators of values). The xsync module (https://github.com/puzpuzpuz/xsync) has those, if you need some inspiration. |
This is similar to #16 |
Could you also consider adding two atomic APIs: Swap and CompareAndSwap?
I have encountered this requirement in my usage scenario, so, I think it's mybee useful too. |
@bagualing |
@lkarlslund @bagualing both |
For concurrent programs a compare and swap value would be really neat, as you might have a race if multiple threads are doing:
The pattern could be changed to
The text was updated successfully, but these errors were encountered: