Skip to content

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

Open
@Eisenwave

Description

@Eisenwave

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions