Liste des Groupes | Revenir à cl c++ |
Am 11.09.2024 um 12:15 schrieb Muttley@dastardlyhq.com:I've been looking at counting_semaphore and it looks useful but something>
that doesn't seem to be properly explained anywhere is the template
parameter value. eg you can do:
std::counting_semaphore sem(2)
which will let a max of 2 threads into the protected block at a time or:
std::counting_semaphore<some number> sem(2)
such as
std::counting_semaphore<10> sem(2)
I don't understand what the '10' will do. ..
The ten gives an upper limit beyond the semaphore wont't increment.
Usually you won't need a C++20 semaphore yourself. For most purpose
the mutex and the condition_variable is sufficient.
Les messages affichés proviennent d'usenet.