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

All atomic operations use the default memory_order_seq_cst #6

Open
JBontes opened this issue Jan 17, 2025 · 0 comments
Open

All atomic operations use the default memory_order_seq_cst #6

JBontes opened this issue Jan 17, 2025 · 0 comments

Comments

@JBontes
Copy link

JBontes commented Jan 17, 2025

Your atomic operations all use the sequentially-consistent ordering. This imposes a hard barrier on all atomic operations. For loads this can be more efficiently replaced with a memory_order_acquire and for stores this should be replaced with memory_order_release. On load/stores (aka CAS operations) you can do: memory_order_acq_rel for success and memory_order_relaxed for failure.
If you happen to have a store after the CAS, you can downgrade the success order to memory_order_acquire.

See: https://en.cppreference.com/w/cpp/atomic/memory_order

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

No branches or pull requests

1 participant