Sunday, 25 August 2013

When is passing a pointer to another thrad in C++11 race condition?

When is passing a pointer to another thrad in C++11 race condition?

title isnt really descriptive so my question is the following. Is the
following code RC free?
auto x = make_shared<Fun>(1984);
auto t = thread(func, x);
Also Herb Sutter in his talk on Cpp and Beyond used concurrent q.
So if I have
auto x = new Fun(1984);
q.push(x);
//other thread
auto ptr = q.pop();
Is this race condition? Aka is it possible for other thread to pop ptr and
still see stale values of mem location where ptr points to? Since
concurrent q is not in the standard lets presume Im using PPL/TBB one.

No comments:

Post a Comment