Sujet : Re: counting_semaphore question
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c++Date : 13. Sep 2024, 08:39:50
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vc0mnm$nseo$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 12/09/2024 16:53,
Muttley@dastardlyhq.com wrote:
On Thu, 12 Sep 2024 07:34:23 -0700
Andrey Tarasevich <andreytarasevich@hotmail.com> boringly babbled:
On 09/12/24 4:00 AM, Muttley@dastardlyhq.com wrote:
>
Clang seems to ignore it. You can call release() as much as you like and
it'll just keep increasing the counter.
>
>
It "ignores" it exactly the same way as the following declaration
>
std::uint_fast8_t n = 2;
>
might "ignore" the 8 in the type name and allow you to increment the
variable well past 255. Come to think of it, the underlying reasons for
Incrementing integrals beyond their max value can have valid uses.
No, it cannot.
A method
allowing you to increment a counter beyond the apparent max counter value -
not so much.
Agreed. That's why you need to put an appropriate max counter value in the template parameter of a std::semaphore. But the /initial/ value of the semaphore counter should often be something other than its /max/ value, thus you need the two numbers.
It is perfectly explained in the spec. And it's been thoroughly
LOL! Ah, a comedian has joined us!
It certainly makes sense in the page at
<
https://en.cppreference.com/w/cpp/thread/counting_semaphore>
and also in the C++ standard.
But those are references - they make it perfectly clear what the template parameter does, and how it affects the preconditions for the constructor and the release() method. However, they do not say /why/ you might want a particular value for the LeastMaxValue. That has been explained in posts in this thread.
You started this thread from a position of ignorance - there was something you did not know, and you asked about it. That is a great way to start.
But for some reason you have moved onto /wilful/ ignorance - you are determined to ignore the information you have been given, to argue with an insult people trying to help you, and to deride the whole concept. I really don't get it. Did you want to know about the template parameter or not?