C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Standard library should have a simple 'gate' for multithreading

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 22 Jul 2022 15:44:26 +0300
On Fri, 22 Jul 2022 at 12:49, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> > > (1) you can open it
> > > (2) you can close it
> > > (3) you can wait for it to open
> > > (4) you can wait for it to close
> >
> > You're describing a pair of std::binary_semaphore.
> > https://en.cppreference.com/w/cpp/thread/counting_semaphore
>

> Messing around with two binary_semaphore's is nonsense, and if you're
> working on a big project with a dozen other programmers, a bug will
> creep in somewhere at some point (you'll get threadlock when somebody
> does "pbs.first.acquire()" instead of "pbs.second.acquire()").
>
> The C++ Standard library should have a simple 'gate'.

You mean like the barrier in
https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4538.pdf ?

Received on 2022-07-22 12:44:38