A lock-free byte-stream ring buffer (mirrors Linux kfifo).
More...
|
|
constexpr auto | capacity () const noexcept -> usize |
| | Returns the total capacity of the buffer.
|
|
auto | peek (std::span< u8 > buf, usize start_offset=0) const noexcept -> usize |
| | Peek data without moving the head pointer.
|
| auto | pop (std::span< u8 > buf) noexcept -> usize |
| | Pop data from the ring buffer.
|
| auto | push (std::span< const u8 > buf) noexcept -> usize |
| | Push data into the ring buffer.
|
|
auto | size () const noexcept -> usize |
| | Returns the total number of bytes currently in the buffer.
|
template<usize N>
requires ((N > 0) && ((N & (N - 1)) == 0))
class lib::ring_buffer< N >
A lock-free byte-stream ring buffer (mirrors Linux kfifo).
- Template Parameters
-
| N | Capacity of the buffer (MUST be a power of two). |
◆ pop()
Pop data from the ring buffer.
- Parameters
-
| [out] | buf | Destination buffer. |
- Returns
- Number of bytes actually read.
◆ push()
Push data into the ring buffer.
- Parameters
-
- Returns
- Number of bytes actually written.
- Note
- This implementation is lockless for single-producer. For multiple producers, external locking is required.
The documentation for this class was generated from the following file: