Boost logo

Boost Users :

Subject: Re: [Boost-users] thread running many times
From: Ytsen de Boer (yrdeboer_at_[hidden])
Date: 2011-09-12 09:34:51


  Looks like you need something like a barrier:
http://www.boost.org/doc/libs/1_47_0/doc/html/thread/synchronization.html#thread.synchronization.barriers

2011/9/11 Kraus Philipp <philipp.kraus_at_[hidden]>:
>
> Am 11.09.2011 um 22:14 schrieb Igor R:
>
>>> I create a thread group and run the group with join_all(). My code shows
>>> like:
>>> for(i=0; i < runs; ++i) {
>>>      threadgoup.join_all();
>>>      do something with the results
>>> }
>>> So I run the thread group n times. Is this the correct way or can I call join_all only once on the group?
>>
>>
>> You do not "run the group with join_all".
>> join_all() waits (blocks) until the execution of all the threads in
>> the group is complete - that's all.
>
> That's correct, because the calls after the join_all need the results of all threads. The algorithm, that I use, has some parallel and serial parts, so I would run the parallel party with a thread group, wait until the group has finished and run the serial part.
>
>
>> This is well documented:
>> http://www.boost.org/doc/libs/1_47_0/doc/html/thread/thread_management.html#thread.thread_management.threadgroup.join_all
>
> I have read the documentation, but there is only the postcondition explained "Every thread in the group has terminated". The algorithm is a iteration algorithm, so I have create code like this:
>
> creating thread group
> for(i=0; i < iterations; ++i) {
>        run threadgroup for parallel part, till all threads finished
>        run serial part
> }
>
> So I would like to ask for, if the thread group is created, and I call the join_all within the loop, each "join_all" starts the full group again on each iteration or need I create a new threadgroup on each iteration (join_all can be called only once on a group)?
>
> Thanks
>
> Phil
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net