
Hi, I would like to know the waiting threads for a condition. Is there a way to calculate the number of "wait()"s which would be affected by a notifiy_all()? Maybe nobody needed this before? Or isn't this possible to implement such a thing with boost::condition and i have to count the waiting threads on the application level? Greetings Manuel Jung

Manuel Jung wrote:
Hi,
I would like to know the waiting threads for a condition. Is there a way to calculate the number of "wait()"s which would be affected by a notifiy_all()?
No. Another thread can issue a notify_one concurrently with your request. You need to encapsulate the condition variable and keep track of the count yourself.

On 3/5/07, Manuel Jung
Hi,
I would like to know the waiting threads for a condition. Is there a way to calculate the number of "wait()"s which would be affected by a notifiy_all()? Maybe nobody needed this before? Or isn't this possible to implement such a thing with boost::condition and i have to count the waiting threads on the application level?
When would this be useful? Note that as soon as you had that info, it would be out of date: int count = condition.number_of_waiters(); // eg: returns 5 // ...another thread starts waiting here condition.notify_all(); // and 6 threads 'notified'
Greetings Manuel Jung
Tony

Gottlob Frege wrote:
On 3/5/07, Manuel Jung
wrote: Hi,
I would like to know the waiting threads for a condition. Is there a way to calculate the number of "wait()"s which would be affected by a notifiy_all()? Maybe nobody needed this before? Or isn't this possible to implement such a thing with boost::condition and i have to count the waiting threads on the application level?
When would this be useful? Note that as soon as you had that info, it would be out of date:
Hi, It wouldnt matter, if its not exact. it is just for monitoring, so i can watch how many threads a waiting approximatly.
int count = condition.number_of_waiters(); // eg: returns 5 // ...another thread starts waiting here condition.notify_all(); // and 6 threads 'notified'
Ill use a "boost::condition::wait" wrapper to count it. Bye Manuel Jung
participants (3)
-
Gottlob Frege
-
Manuel Jung
-
Peter Dimov