|
Boost : |
From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2005-09-15 01:54:26
Roland Schwarz schrieb:
>Matt Hurd schrieb:
>
>
>
>>> { // we wait until all threads are up
>>> lock_type lock(guard);
>>> while (global_number_of_threads <
>>> number_of_threads_for_test+1)
>>> cond.wait(lock);
>>> }
>>>
>>>
>>>
>>>
>>I can't see why you get here? I might be missing something but you're
>>likely to end up with all threads waiting on conditions here...
>>
>>
>>
Oh so sorry, I did not answer your question, but instead just started
to answer another one which seemed more interesting to me ;-)
The upstarting threads increment this global_number_threads as their
first statement. Your code snippet simply waits until all increments
are done, at which point the numer is equal to the number to the
threads that have been put into the pool. The shown code snippet
shows testing this predicate.
If you fire this up and set a breakpoint just at the start of the follwing
loop, you can see that main indeed will stop at this breakpoint.
Regards,
Roland
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk