1
General Discussion about just::thread / jss::synchronized_value
« on: April 23, 2013, 11:41:40 AM »
In the example given:
jss::synchronized_value<std::string> s;
void foo(){
if(s->empty()){
*s = "hello";
}
}
Is there not a race condition between checking for empty and then assigning to s? Presumably another thread could write to s after the empty check but before the assignment? Or does synchronized_value somehow protect against this?
jss::synchronized_value<std::string> s;
void foo(){
if(s->empty()){
*s = "hello";
}
}
Is there not a race condition between checking for empty and then assigning to s? Presumably another thread could write to s after the empty check but before the assignment? Or does synchronized_value somehow protect against this?