Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-12-06 10:27:52


Dan Dimerman wrote:
> "Ben Hutchings" <ben.hutchings_at_[hidden]> wrote in message
> news:41B47000.1030500_at_businesswebsoftware.com...
>
>>That still won't solve your problem, in general. Multithreading is an /
>>... /
>>You should protect all access to the controlling flag with a mutex. In
>>this case it would probably be sufficient to use the "volatile" qualifier
>>on the controlling member, but this is not generally a good solution.
>>Ben.
>
>
> In this case, I think the problem was that by {mis,ab,}using the boost
> thread lib, I passed a copy of
> the functor that would be the worker thread instead of just a reference to
> it, hence the duplicity.
> Protecting that variable with a mutex wouldn't have had any effect, since
> there would have been two copies still.

I realise that, but I think eliminating the copy only solves half the
problem.

Ben.


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