Boost logo

Boost :

Subject: Re: [boost] [Boost.Lockfree] Interest in a ringbuffer class
From: Raphaël Londeix (raphael.londeix_at_[hidden])
Date: 2017-01-26 06:18:30


>
> I'd agree with Tim that the spsc_queue is too similar to the proposed
> ringbuffer to make much sense. Any additions need to be more
> significantly different like say the ringbuffer log mentioned.
>

Somehow I failed to sell correctly my idea, but unless I missed something,
it's not possible to store buffers of different sizes inside a spsc_queue.
(of course it is possible if you can afford using some external storage,
like the heap)

The proposed ringbuffer is quite different in that is only stores raw
buffers,
and allow one to do that without any extra copy.

For example, one could read from a socket in one thread, while handling
them in another:

     if (auto buf = rb.start_write(1500)) {
         ssize_t read_size = ::read(fd, &buf.data[0], 1500);
         if (read_size > 0)
            rb.commit_write(read_size);
    }

Of course, one could use a `spsc_queue<std::array<char, 1500>>' but if most
of your packets are 100 bytes, it's just a waste of space.

Given those two points (zero-copy, buffers of different size), do you still
think it's
too similar to spsc_queue ?

-- 
Raphaël Londeix
http://hotgloupi.fr

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