I'm getting a bit confused with the new threading in C++11. I get how I can use mutexes to stop two threads from operating on the same data at the same time, but what about assigning to that data?
Example!
class Foo
{
std::string s;
// This would be called on a seperate thread
void Bar() { s = std::string( "blah blah blah" ); }
};
So what I'm asking is, because I'm assigning something to s, does the member variable s always stay in the same memory location, and assignments just change the internal data, in which case I just need a mutex? Or can I still get into situations with cached values and things which mean I need to start using atomic<> to make sure I have the up to date data? Or is that just for types like ints, or structs?