C++ Logo


Advanced search

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

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Fri, 22 Jul 2022 10:55:05 -0400
I don't really like the idea of standard library functionality that
exists only to help learners learn the languages. I'm fine with
functionality that is easy to learn and use, but ultimately it should
be *useful* functionality to actual C++ programmers.

When you don't do that, you get things like iostreams: an ostensibly
useful set of types that have some nice features and are really easy
to learn, but ultimately are too slow and unwieldy for serious C++
developers to bother with. We didn't add `std::format` just for
learners; we added it for everyone (though even it has some flaws).

Similarly, `jthread` wasn't created just for new C++ programmers. It
exists to plug a big hole in the `thread` type, a hole that actual
working programmers sometimes fall into. It also adds a convenience
feature for asking a thread to stop, but you don't even have to use

Is this `gate` class a useful enough tool for working C++ programmers?
Equally importantly, will `gate` teach people bad practices for how to
do threaded programming?

Received on 2022-07-22 14:57:36