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

Use std::atomic<bool> instead of std::atomic_flag unless you have a good reason #2234

Open
Eisenwave opened this issue Nov 8, 2024 · 0 comments

Comments

@Eisenwave
Copy link
Contributor

I was surprised that we don't have a recommendation on this in the concurrency section.

The gist of it is that you should prefer std::atomic<bool> by default. std::atomic_flag is guaranteed to be lock-free, but it also has a less usual API and is lock-free at all cost, even if that means doing something insanely costly like locking the entire memory bus.

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