data.buffer.burst_write ≡
template <typename T, auto BufferSize, auto BurstSize = BufferSize> class burst_write_buffer §source
Buffer that accumulates a given number of entries, and then invokes a callback one or more times to write those values to e.g. DRAM in a burst.
Parameters
-
typename TType of each entry of the buffer
-
auto BufferSizeNumber of elements to buffer. Must be a power of 2.
-
auto BurstSize = BufferSizeNumber of elements to store before invoking the
write_callbck. Must be a power of 2 andBurstSize<=BufferSize.
Aliases
Methods
-
inline burst_write_buffer::buffer_count_t count() §source
Return the number of elements that have been written and not yet sent to the callback. Note that this can be out of date the instant it is read due to other threads writing to the buffer.
-
inline void write( T value, bool flush_now, ( T value, burst_write_buffer::burst_count_t index, bool is_last ) -> void write_callback ) §source
Write one entry to the buffer. May invoke the
write_callbackfunction.Arguments
-
T valueThe value to write.
-
bool flush_now
If true, the callback will be invoked for any buffered values, even if there are fewer than
BurstSizevalues buffered. -
( T value, burst_write_buffer::burst_count_t index, bool is_last ) -> void write_callback
The function to call when
BurstSizeentires have been written.Arguments
-
T valueThe value to write in the callback.
-
burst_write_buffer::burst_count_t index
The index of this callback within the burst. Between 0 and
BurstSize- 1 inclusive. -
bool is_last
True if this is the last value within this burst, false otherwise.
-
-
Invariants
-
(0 == (BufferSize & (BufferSize - 1)))
BufferSizemust be a power of 2. -
(0 == (BurstSize & (BurstSize - 1)))
BurstSizemust be a power of 2. -
(BurstSize <= BufferSize)