2 ms·
There are multiple ways to make a lock-free ringbuffer; most use some sort of similar trick with per-consumer atomic counters, though I hadn't heard of somethin
by btown 11y ago
There are multiple ways to make a lock-free ringbuffer; most use some sort of similar trick with per-consumer atomic counters, though I hadn't heard of something as simple as the minimum-modulo trick described in the gp! Some implementations:
http://mechanitis.blogspot.com/2011/07/dissecting-disruptor-writing-to-ring.html http://mechanitis.blogspot.com/2011/07/dissecting-disruptor-...
http://www.boost.org/doc/libs/1_59_0/doc/html/boost/lockfree/queue.html http://www.boost.org/doc/libs/1_59_0/doc/html/boost/lockfree... - hard to find implementation details though
http://moodycamel.com/blog/2014/a-fast-general-purpose-lock-free-queue-for-c++ http://moodycamel.com/blog/2014/a-fast-general-purpose-lock-... (uses per-producer counters instead, and relaxes some ordering guarantees; see comments)