Re: counting_semaphore question

Liste des GroupesRevenir à cl c++ 
Sujet : Re: counting_semaphore question
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++
Date : 11. Sep 2024, 17:27:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbscsd$3ltfs$1@raubtier-asyl.eternal-september.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Am 11.09.2024 um 17:03 schrieb Muttley@dastardlyhq.com:
On Wed, 11 Sep 2024 07:37:13 -0700
Andrey Tarasevich <andreytarasevich@hotmail.com> boringly babbled:
On 09/11/24 3:15 AM, Muttley@dastardlyhq.com wrote:
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:
>
No, there's nothing "max" about that 2 here. 2 means that the semaphore
will be created with 2 available "permissions to enter" (permissions to
`acquire()`) initially. The number of available "permissions" can be
increased by calling `release()` after creating the semaphore. Call
`release()` 3 more times on our semaphore right away, and the initial 2
will increase to 5. So, 2 is not "max".
>
The "max" is set by the template parameter `LeastMaxValue`.
 It seems I'm not the only one getting confused here. If I write:
 std::counting_semaphore<10> sem(2)
 then the semaphore can only be aquired TWO times, not 10. I don't understand
what the 10 is supposed to do as changing the 10 to 0,1 or 1000 makes no
difference whatsoever to how many times acquire() can be called before
release() is called in the tests I've done.
10 is the maximum count the semaphore is allowed to reach, therefore binary_semaphore, which is an alias-template to counting_semaphore<1>,
has a maximum count of one.

Date Sujet#  Auteur
11 Sep 24 * counting_semaphore question78Muttley
11 Sep 24 +* Re: counting_semaphore question63Bonita Montero
11 Sep 24 i`* Re: counting_semaphore question62Muttley
11 Sep 24 i `* Re: counting_semaphore question61Bonita Montero
11 Sep 24 i  +* Re: counting_semaphore question27Muttley
11 Sep 24 i  i+* Re: counting_semaphore question2Bonita Montero
11 Sep 24 i  ii`- Re: counting_semaphore question1Muttley
11 Sep 24 i  i+* Re: counting_semaphore question10David Brown
16 Sep23:22 i  ii`* Re: counting_semaphore question9Chris M. Thomasson
17 Sep09:22 i  ii `* Re: counting_semaphore question8David Brown
17 Sep20:56 i  ii  `* Re: counting_semaphore question7Chris M. Thomasson
18 Sep09:32 i  ii   `* Re: counting_semaphore question6David Brown
19 Sep12:57 i  ii    `* Re: counting_semaphore question5Bonita Montero
19 Sep13:01 i  ii     +- Re: counting_semaphore question1Bonita Montero
19 Sep21:09 i  ii     +- Re: counting_semaphore question1Chris M. Thomasson
19 Sep22:27 i  ii     `* Re: counting_semaphore question2Chris M. Thomasson
19 Sep22:30 i  ii      `- Re: counting_semaphore question1Chris M. Thomasson
12 Sep 24 i  i`* Re: counting_semaphore question14Ben Bacarisse
12 Sep 24 i  i `* Re: counting_semaphore question13Muttley
12 Sep 24 i  i  `* Re: counting_semaphore question12Andrey Tarasevich
12 Sep 24 i  i   `* Re: counting_semaphore question11Muttley
13 Sep 24 i  i    +* Re: counting_semaphore question9David Brown
13 Sep 24 i  i    i`* Re: counting_semaphore question8Muttley
13 Sep 24 i  i    i `* Re: counting_semaphore question7David Brown
13 Sep 24 i  i    i  `* Re: counting_semaphore question6Muttley
13 Sep 24 i  i    i   +* Re: counting_semaphore question3Bonita Montero
13 Sep 24 i  i    i   i+- Re: counting_semaphore question1Muttley
15 Sep17:33 i  i    i   i`- Re: counting_semaphore question1David Brown
13 Sep 24 i  i    i   `* Re: counting_semaphore question2David Brown
13 Sep 24 i  i    i    `- Re: counting_semaphore question1Muttley
13 Sep 24 i  i    `- Re: counting_semaphore question1Andrey Tarasevich
11 Sep 24 i  `* Re: counting_semaphore question33Chris M. Thomasson
12 Sep 24 i   `* Re: counting_semaphore question32Bonita Montero
12 Sep 24 i    `* Re: counting_semaphore question31Chris M. Thomasson
13 Sep 24 i     `* Re: counting_semaphore question30Bonita Montero
13 Sep 24 i      `* Re: counting_semaphore question29Chris M. Thomasson
14 Sep 24 i       `* Re: counting_semaphore question28Bonita Montero
14 Sep 24 i        +* Re: counting_semaphore question2Chris M. Thomasson
14 Sep21:07 i        i`- Re: counting_semaphore question1Chris M. Thomasson
14 Sep11:18 i        `* Re: counting_semaphore question25Muttley
14 Sep11:40 i         `* Re: counting_semaphore question24Bonita Montero
14 Sep12:58 i          +* Re: counting_semaphore question22Muttley
14 Sep13:15 i          i`* Re: counting_semaphore question21Bonita Montero
14 Sep17:13 i          i +* Re: counting_semaphore question12Muttley
14 Sep17:26 i          i i`* Re: counting_semaphore question11Bonita Montero
14 Sep17:48 i          i i `* Re: counting_semaphore question10Muttley
14 Sep17:50 i          i i  `* Re: counting_semaphore question9Bonita Montero
14 Sep17:55 i          i i   `* Re: counting_semaphore question8Muttley
14 Sep17:57 i          i i    `* Re: counting_semaphore question7Bonita Montero
15 Sep11:05 i          i i     `* Re: counting_semaphore question6Muttley
15 Sep11:48 i          i i      `* Re: counting_semaphore question5Bonita Montero
15 Sep11:52 i          i i       `* Re: counting_semaphore question4Muttley
15 Sep14:50 i          i i        `* Re: counting_semaphore question3Bonita Montero
15 Sep17:28 i          i i         `* Re: counting_semaphore question2Muttley
16 Sep05:02 i          i i          `- Re: counting_semaphore question1Bonita Montero
14 Sep21:12 i          i `* Re: counting_semaphore question8Chris M. Thomasson
15 Sep02:21 i          i  +- Re: counting_semaphore question1Chris M. Thomasson
15 Sep07:11 i          i  `* Re: counting_semaphore question6Bonita Montero
15 Sep07:20 i          i   `* Re: counting_semaphore question5Chris M. Thomasson
15 Sep09:35 i          i    `* Re: counting_semaphore question4Bonita Montero
15 Sep21:59 i          i     `* Re: counting_semaphore question3Chris M. Thomasson
16 Sep05:04 i          i      `* Re: counting_semaphore question2Bonita Montero
16 Sep22:30 i          i       `- Re: counting_semaphore question1Chris M. Thomasson
14 Sep21:09 i          `- Re: counting_semaphore question1Chris M. Thomasson
11 Sep 24 `* Re: counting_semaphore question14Andrey Tarasevich
11 Sep 24  `* Re: counting_semaphore question13Muttley
11 Sep 24   +* Re: counting_semaphore question6Bonita Montero
11 Sep 24   i`* Re: counting_semaphore question5Muttley
11 Sep 24   i +* Re: counting_semaphore question3Bonita Montero
11 Sep 24   i i`* Re: counting_semaphore question2Muttley
12 Sep 24   i i `- Re: counting_semaphore question1Bonita Montero
12 Sep 24   i `- Re: counting_semaphore question1Chris M. Thomasson
12 Sep 24   `* Re: counting_semaphore question6Andrey Tarasevich
12 Sep 24    `* Re: counting_semaphore question5Muttley
12 Sep 24     +* Re: counting_semaphore question2David Brown
12 Sep 24     i`- Re: counting_semaphore question1Muttley
12 Sep 24     +- Re: counting_semaphore question1Bonita Montero
12 Sep 24     `- Re: counting_semaphore question1Andrey Tarasevich

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal