C++ Logo

std-proposals

Advanced search

Re: [std-proposals] unique_lock<atomic_flag>

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 23 Feb 2023 00:21:44 +0000
On Wed, Feb 22, 2023, Jason McKesson wrote:
>
> You replace your `atomic_flag` with a `binary_semaphore`, and replace
> your `while` loop with `acquire()` in the constructor, and have the
> destructor do a `release()`.


Yeah that's what I was thinking. I might go through my projects and
replace the atomic_flag's with binary semaphores.

But anyway I still think you should be able to acquire and release a
semaphore using 'lock_guard' or 'unique_lock', like this:

    https://godbolt.org/z/6xx7E8xsq

Received on 2023-02-23 00:21:56