Relative Content

Tag Archive for c++concurrencyconcurrent-queue

Why do we need this additional check in this concurrent queue implementation?

Working through a textbook which suggests the following implementation for a concurrent queue. I am wondering why the two if statements, which are highlighted in the code, are necessary. After the snippet I include some reasoning about why I don’t think they are necessary, but I’m still hesitant to go against the word of my textbook, so I would love some explanation about why we need these.