Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-12-06 09:43:12


Dan Dimerman wrote:
> Hello Cory,
> Thank you for your response.
> No, I'm ashamed to say, I didn't pass a boost::ref to the boost::thread.
> And you sir, have hit a bull's eye.
<snip>

That still won't solve your problem, in general. Multithreading is an
entirely non-standard extension to C++. Libraries like Boost.Thread go
part way to providing portability, but memory semantics are troublesome.
Actual implementations do not guarantee that changes to memory in one
thread become visible in another thread in the same order, or at all.
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.


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