I'm would like to receive directly into a boost::lockfree:spsc_queue (or, alternatively, a boost::circular_buffer) from a boost::asio::async_read call. Looks like I need to write a wrapper to make the spsc_queue a MutableBuffer.
Can anyone share some guidance on if this is possible, and how to achieve this?
Many thanks
Each receive buffer must be contiguous when using
asio.Since
boost::circular_bufferis not contiguous it is rather inconvenient to use as a byte buffer. Still, though, you can present it toasioas 2 buffers with scatter-gather I/O.An efficient and convenient circular buffer for I/O is a region of memory pages mapped twice without any padding between them. This way you can read into your circular buffer with one
readsyscall, without having to use scatter-gather I/O and without having to deal with buffer discontinuity when parsing/reading its contents.