I have class where a bool is access concurrently. However in my case it is only initialized to false once in the constructor, and after that it set to false. Am i correct to believe that even though a race might occur the result will be valid and defined? Since the entire bool doesn't have to be written to inorder for "!isStopping_" to evaluate to true.
class MyClass
{
public:
MyClass() : isStopping_(false), thread_([=]{Run();}) {}
void Stop()
{
isStopping_ = true;
}
private:
void Run()
{
while(!isStopping_) // data race
{
// Work
}
}
bool isStopping_ ;
boost::thread thread_;
};