Boost logo

Boost :

Subject: Re: [boost] [thread] basic mutex problem
From: Greg Rubino (bibil.thaysose_at_[hidden])
Date: 2011-08-13 09:55:02


On Sat, Aug 13, 2011 at 9:53 AM, Greg Rubino <bibil.thaysose_at_[hidden]> wrote:
> 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.

Yep, that worked... How embarrassing...

Thanks again!

>
> 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