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 T
    

    Type of each entry of the buffer

  • auto BufferSize
    

    Number of elements to buffer. Must be a power of 2.

  • auto BurstSize = BufferSize
    

    Number of elements to store before invoking the write_callbck. Must be a power of 2 and BurstSize <= 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_callback function.

    Arguments

    • T value
      

      The value to write.

    • bool flush_now
      

      If true, the callback will be invoked for any buffered values, even if there are fewer than BurstSize values buffered.

    • ( T value, burst_write_buffer::burst_count_t index, bool is_last
      ) -> void write_callback
      

      The function to call when BurstSize entires have been written.

      Arguments

      • T value
        

        The 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)))
    

    BufferSize must be a power of 2.

  • (0 == (BurstSize & (BurstSize - 1)))
    

    BurstSize must be a power of 2.

  • (BurstSize <= BufferSize)