C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 21 Jul 2022 19:36:33 -0700
On Thursday, 21 July 2022 16:38:16 PDT Frederick Virchanza Gotham via Std-
Proposals wrote:
> The reusable code I have for a 'gate' class (which I use in my own
> programs) starts off with the gate closed, and it has a very simple
> interface:
> (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

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2022-07-22 02:36:35