On 26/01/2017 10:56, Raphaƫl Londeix wrote:
the ringbuffer will be basically using the same algorithm as the spsc_queue under the hood, but basically separate 'algorithm' from 'storage', right?
That's right, but that's not the main selling point. The idea is to be able to store raw buffers of different sizes, without any external storage or indirection. When you do
buffer* buf = rb.start_write(10);
The variable `buf' is stored inside the ring buffer, so that the commit operation only change the position of the write cursor. One possible way to do that is to define buffer as
Personally speaking, if you're not using fixed size (and usually cache line aligned) items in thread shared memory storage, you've probably got the wrong design. For example, if I were accumulating UDP packets using many threads, I'd keep a ring buffer per thread and timestamp their arrival using RDTSC so they could be reassembled into received order later if needed. That avoids multiple threads modifying the same memory which can become hideously slow. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/