-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
add documentation for atomics #1516
Comments
I need this, I wasn't able to understand it reading the documentations of other languages, |
If someone need this, I recommend this article: https://dev.to/kprotty/understanding-atomics-and-memory-ordering-2mom |
Both
That does not match the code snippet: fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_value: T) ?T {
const old_value = ptr.*;
if (old_value == expected_value) {
ptr.* = new_value;
return null;
} else {
return old_value;
}
} Assuming the code snippet is correct, then should it read:
|
The previous wording was incorrect as it indicated that `@cmpxchgStrong` and `@cmpxchgWeak` return `null` on "failure" even though it returns `null` on success and the current value of the atomic on "failure", see ziglang#19979. Further documentation might be helpful as described in ziglang#1516.
moved from #367
@fence
@cmpxchgStrong
and@cmpxchgWeak
@atomicRmw
volatile
The text was updated successfully, but these errors were encountered: