Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - py

Pages: [1]
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?

Pages: [1]