Commit Graph

10 Commits

Author SHA1 Message Date
Martin Piatka
f9d2156e23 ring_buffer: Fix warn about too big write when writing 0 bytes 2023-07-28 12:33:13 +02:00
Martin Piatka
2dee9ff16d ring_buffer: assert size > 0
Otherwise it crashes elsewhere on division by 0.
2022-03-18 14:15:30 +01:00
Martin Piatka
c580a3b3a1 ring_buffer: Replace malloc/free with C++ memory management
The ring_buffer struct contains std::atomic which is a c++ object and
has a constructor, which is not called if the struct is malloc'ed.

This probably wasn't really an issue, since the constructor for those
doesn't do anything interesting anyway.
2022-03-18 14:13:14 +01:00
Martin Piatka
b065dd8117 ring_buffer: add fill() function 2022-03-18 14:11:42 +01:00
Martin Piatka
250eafdb48 ring_buffer: expose the zero-copy interface 2022-01-10 12:28:16 +01:00
Martin Piatka
59f547a261 ring_buffer: Allow using the whole buffer
Previously it was possible to only use size - 1B, because filling the
whole buffer would make start and end indices equal, making the buffer
appear empty. This is important if we want to allow direct zero-copy
access to the buffer while storing multi-byte elements.
2022-01-10 12:28:15 +01:00
Martin Piatka
7ae866a08a ring_buffer: split read into get_regions and advance_idx 2022-01-10 09:51:13 +01:00
Martin Piatka
a87a518ed1 ring_buffer: split write into get_regions and advance_idx 2022-01-10 09:51:12 +01:00
Martin Piatka
6bf2b60839 ring_buffer: simplify write overflow detection 2022-01-10 09:51:12 +01:00
Martin Piatka
f796e62e16 ring_buffer: replace volatile with atomic int for start, end indices 2022-01-10 09:51:12 +01:00