Boost logo

Boost :

Subject: Re: [boost] [Boost.Lockfree] Interest in a ringbuffer class
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-01-26 07:22:56


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/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk