data.buffer.cyclic


template <
    typename T,
    auto WordSize,
    auto ReadWordSize,
    auto TotalSize,
    typename AddrType = uint64
    >
class unaligned_cyclic_buffer §source

A cyclic buffer with the following functionality:

  • One data word can be written at a time until the buffer is full
  • Words can be freed to create new write space in a FIFO manner
  • Any valid element (written and not freed) can be read, even if not aligned to a word boundary

Parameters

  • typename T
    

    Type of each element of the buffer.

  • auto WordSize
    

    Number of elements per data word.

  • auto ReadWordSize
    

    Number of elements to be returned per read. Must be <= to WordSize.

  • auto TotalSize
    

    Total size of memory in elements.

  • typename AddrType = uint64
    

    Type to accumulate number of written and freed words. Ensure this will not overflow between calls to reset. Additionally, used to access and free buffer elements.

Aliases

Methods

template <typename T, auto Size, typename AddrType = uint64>
class cyclic_buffer §source

This class is a wrapper around a unaligned_cyclic_buffer with WordSize == 1.

Parameters

  • typename T
    

    Type of each entry in the buffer.

  • auto Size
    

    Maximum number of entries that can be stored.

  • typename AddrType = uint64
    

    Type to accumulate number of written and freed words. Ensure this will not overflow between calls to reset. Additionally, used to access and free buffer elements.

Aliases

Methods

  • void reset() §source
    

    Reset cyclic buffer. This is not thread-safe and should not be called while any other functions are running.

  • void write(T val) §source
    

    Wait for a free entry and write one entry.

  • void free(cyclic_buffer::addr_t addr) §source
    

    Free entries up to the specified address. Caller should ensure that this address is valid.

    Arguments

  • void wait(cyclic_buffer::addr_t addr) §source
    

    Block until the passed address has been written to.

    Arguments

  • T read(cyclic_buffer::addr_t addr) §source
    

    Wait for the entry at addr to be written and then read the value. The caller should ensure that this is not called for a free entry.

    Arguments

  • inline T nonblocking_read(cyclic_buffer::addr_t addr) §source
    

    Read the value at the specified address. This version of read does not block to wait for the entry to be written. It is also inline to reduce the cost of multiple callsites. The caller should ensure that the address is valid (written and not freed).

    Arguments