#include <spsc_ring_index.hpp>
◆ SpscRingIndex() [1/3]
| pulp::runtime::SpscRingIndex::SpscRingIndex |
( |
int | capacity | ) |
|
|
inlineexplicitnoexcept |
Construct an SpscRingIndex that manages indices in [0, capacity).
capacity is the size of the caller-owned buffer in items. One slot is reserved internally as the empty/full sentinel, so the maximum number of items that can ever be queued is capacity - 1. Pick a capacity one larger than the worst-case queue depth you need.
◆ SpscRingIndex() [2/3]
| pulp::runtime::SpscRingIndex::SpscRingIndex |
( |
const SpscRingIndex & | | ) |
|
|
delete |
◆ SpscRingIndex() [3/3]
| pulp::runtime::SpscRingIndex::SpscRingIndex |
( |
SpscRingIndex && | | ) |
|
|
delete |
◆ capacity()
| int pulp::runtime::SpscRingIndex::capacity |
( |
| ) |
const |
|
inlinenoexcept |
Total size of the managed buffer in items.
◆ finish_read()
| void pulp::runtime::SpscRingIndex::finish_read |
( |
int | num_read | ) |
|
|
inlinenoexcept |
Advance the read cursor by num_read items.
◆ finish_write()
| void pulp::runtime::SpscRingIndex::finish_write |
( |
int | num_written | ) |
|
|
inlinenoexcept |
Advance the write cursor by num_written items.
Must be called after the caller has copied data into the ranges returned by prepare_to_write(). Passing more than the prepared sum is a programming error and is clamped to keep the fifo coherent.
◆ free_space()
| int pulp::runtime::SpscRingIndex::free_space |
( |
| ) |
const |
|
inlinenoexcept |
Free space (in items) available for new writes.
The fifo reserves one slot internally, so this is at most capacity - 1.
◆ num_ready()
| int pulp::runtime::SpscRingIndex::num_ready |
( |
| ) |
const |
|
inlinenoexcept |
Number of items currently available to read.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ prepare_to_read()
| void pulp::runtime::SpscRingIndex::prepare_to_read |
( |
int | num_to_read, |
|
|
int & | start_1, |
|
|
int & | size_1, |
|
|
int & | start_2, |
|
|
int & | size_2 ) const |
|
inlinenoexcept |
Plan a read of up to num_to_read items.
Returns two ranges the caller may copy out of its buffer. Sum is min(num_to_read, num_ready()). The cursor is NOT advanced until finish_read() is called.
◆ prepare_to_write()
| void pulp::runtime::SpscRingIndex::prepare_to_write |
( |
int | num_to_write, |
|
|
int & | start_1, |
|
|
int & | size_1, |
|
|
int & | start_2, |
|
|
int & | size_2 ) const |
|
inlinenoexcept |
Plan a write of up to num_to_write items.
Returns two index ranges [start_1, start_1+size_1) and [start_2, start_2+size_2) covering contiguous regions of the caller-owned buffer that may be filled. size_2 is non-zero only when the write wraps past capacity. The sum size_1 + size_2 is min(num_to_write, free_space()). The cursor is NOT advanced until finish_write() is called.
◆ reset()
| void pulp::runtime::SpscRingIndex::reset |
( |
| ) |
|
|
inlinenoexcept |
Reset the cursors back to empty.
Not thread-safe — the caller must guarantee neither producer nor consumer is active.
The documentation for this class was generated from the following file: