M***@dastardlyhq.com
2024-09-11 10:15:15 UTC
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. Its returned by the max()
method but whats its purpose since if its the maximum possible threads
you could have in the protected block it makes no sense because you can't
change that value after creation as far as I can see.
Thanks for any help.
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. Its returned by the max()
method but whats its purpose since if its the maximum possible threads
you could have in the protected block it makes no sense because you can't
change that value after creation as far as I can see.
Thanks for any help.