|
Boost : |
Subject: Re: [boost] [thread] basic mutex problem
From: Greg Rubino (bibil.thaysose_at_[hidden])
Date: 2011-08-13 09:53:07
2011/8/13 ЮÑÑй ÐÑбÑиÑÑкий <mt.wizard_at_[hidden]>:
> What do I see is that you hold const reference to ptime in
> random_activity_planner, but pass it by value to ctor. This isn't
> correct, as const reference prolongs life of ctor parameter only until
> ctor body end. Try changing either of these places (hold by value or
> pass by cref).
> Looks like when you don't threads stack place where copied ptime lived
> isn't reused, but with threads it is rewritten.
Aha, my mistake! Thanks for pointing that out! I think I'd rather
pass by ref, I will try it soon.
Thanks again,
Greg
>
> 2011/8/13 Greg Rubino <bibil.thaysose_at_[hidden]>
>>
>> On Fri, Aug 12, 2011 at 3:15 PM, Christian Holmquist
>> <c.holmquist_at_[hidden]> wrote:
>> >> Also, I am aware that I don't need to be
>> >> using threads here, but I am, and I don't understand why it's not
>> >> working.
>> >>
>> >>
>> > Does the code do the right thing if you remove the threads and just call
>> > random_activity_planner(activities,origin)();
>> > directly?
>>
>> Hi Christian,
>>
>> Thanks for the quick response! Â I tried that and it behaves as
>> expected if I remove the uses of boost::thread_group. Â That is, the
>> container grows to activity_count elements and they are all properly
>> initialized with random elements.
>>
>> Greg
>> >
>> > - Christian
>> > _______________________________________________
>> > Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>> >
>> _______________________________________________
>> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk