Template Class PcBufferReader#

Inheritance Relationships#

Derived Types#

Class Documentation#

template<class T, typename element_t = std::byte>
class PcBufferReader#

A producer-consumer buffer-reader interface class.

Template Parameters:

Subclassed by Coral::PcBuffer< tx_depth, element_t, sizeof(element_t) >, Coral::PcBuffer< rx_depth, element_t, sizeof(element_t) >, Coral::PcBuffer< tx_depth, std::byte, sizeof(std::byte) >, Coral::PcBuffer< rx_depth, std::byte, sizeof(std::byte) >, Coral::PcBuffer< depth, element_t, alignment, Lock >

Public Functions

inline Result pop(element_t &elem)#

Attempt to read an element from the buffer.

Parameters:

elem[out] The element to be written.

Returns:

Whether or not elem was written.

template<std::size_t N>
inline Result pop(std::array<element_t, N> &elem_array)#

Attempt to read buffer elements into an array.

Template Parameters:

N – The size of elem_array.

Parameters:

elem_array[out] The array to write elements to.

Returns:

Whether or not elem_array was written. Otherwise no elements are read.

inline Result pop(std::span<element_t> &elem_span)#

Attempt to read buffer elements into a span.

Parameters:

elem_span[out] The span to write elements to.

Returns:

Whether or not elem_array was written. Otherwise no elements are read.

inline Result pop_n(element_t *elem_array, std::size_t count)#

Attempt to read an array from the buffer.

Parameters:
  • elem_array[out] The array to write data to.

  • count[in] The number of elements to read.

Returns:

Whether or not all count elements were read. When false, no elements were read.

template<std::size_t N>
inline std::size_t try_pop_n(std::array<element_t, N> &elem_array)#

Attempt to read an array’s worth of elements from the buffer. Partial progress is made if possible.

Template Parameters:

N – The size of elem_array.

Parameters:

elem_array[out] The array to write elements to.

Returns:

The number of elements actually read. Always between zero and the size of elem_array.

inline std::size_t try_pop_n(std::span<element_t> &elem_span)#

Attempt to read a span’s worth of elements from the buffer. Partial progress is made if possible.

Parameters:

elem_span[out] The span to write elements to.

Returns:

The number of elements actually read. Always between zero and the size of elem_array.

inline std::size_t try_pop_n(element_t *elem_array, std::size_t count)#

Attempt to read a specific number of elements from the buffer. Partial progress is made if possible.

Parameters:
  • elem_array[out] Same as pop_n.

  • count[in] Same as pop_n.

Returns:

The number of elements actually read. Always between zero and count.

inline std::size_t pop_all(element_t *elem_array = nullptr)#

Read all available elements from the buffer.

Parameters:

elem_array[out] Same as pop_n. If not provided, elements are read but data is discarded.

Returns:

The number of elements read.