Liste des Groupes | Revenir à cl c++ |
Am 11.09.2024 um 18:04 schrieb Muttley@dastardlyhq.com:
>We're going around in circles. Instead of reading the man page how about>
trying some code. How many times to you think this loop will run before it
hangs? 100 or 2?
#include <stdio.h>
#include <semaphore>
std::counting_semaphore<100> sem(2);
int main()
{
for(int i=0;;++i)
{
sem.acquire();
printf("Acquired %d\n",i);
}
return 0;
}
Answer: 2
There's nothing wrong with what I said. Once the semaphore is created
its maximum count isn't relevant any more. The return statement isn't
Les messages affichés proviennent d'usenet.