After a writer has written to its reserved write location, it can only make the
location available for reading if all of the writers with lower locations have
finished.
Fix a race where the reader would see the updated the tail pointer before the
write could write the data into the queue. Fix this by having a separate reader
tail pointer that is only incremented after the writer wrote the data.
See #651514 for details. It's apparently impossible to write code
that avoids both type punning warnings with old g_atomic headers and
assertions in the new. Thus, macros and a version check.
Add an atomic queue. The queue can be used from multiple threads simultaneously
and without taking any locks or doing any blocking operations. This makes it
highly scalable for things like the bus, bufferpools and object recycling.