4 ms·
I agree. It looks like their read implementation means that every thread pops the same item off as well, since they clone to a temp variable.
by mentat 15y ago
I agree. It looks like their read implementation means that every thread pops the same item off as well, since they clone to a temp variable.
- jey 15y agoThreads have separate stacks and the call to front() and pop_front() is protected by the mutex, so that part is fine as far as I can see.
- mentat 15y agoI'm not familiar with the STL implementation, but it seems the pop would need to be coherent with the push in an empty stack. Like if a thread was trying to pop the only entry while another was trying to push, 'intuitively' there'd be a race condition there if STL isn't thread safe (which is the whole point of the article I think).