11 Jul
2008
11 Jul
'08
3:31 p.m.
Even if the element were returned by value, the following code would
suffer from the race condition:
element = my_conatiner.front();
// here -- the front element might already have been popped here by
another thread!
my_container.pop();
or:
if (!my_container.empty())
{
// the container might already be empty here!
element = my_container.front();
}
2008/7/11, Khandelwal, Amit
Agreed. I didn't realize that I had typed return by reference. My bad.