Template Class PcBufferWriter#

Inheritance Relationships#

Derived Types#

Class Documentation#

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

A producer-consumer buffer-writer interface class.

Template Parameters:
  • T – Implementing class (CRTP).

  • element_t – The kind of element the buffer stores.

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 push(const element_t &elem, bool drop = false)#

Attempt to push a single element into the buffer.

Parameters:
  • elem[in] The element to attempt adding.

  • drop[in] Whether or not to consider this element dropped if it can’t be added.

Returns:

Whether or not the element was added to the buffer.

inline void push_blocking(const element_t &elem)#

Push a single element into the buffer and block until it’s added.

Parameters:

elem[in] The element to add.

template<std::size_t N>
inline Result push(const std::array<element_t, N> &elem_array, bool drop = false)#

Attempt to push an array into the buffer.

Template Parameters:

N – The size of elem_array.

Parameters:
  • elem_array[in] The array to push data from.

  • drop[in] Whether or not to consider the array elements dropped if they can’t all be pushed.

Returns:

Whether or not the entire array was pushed. No elements are pushed otherwise.

inline Result push(const std::span<element_t> &elem_span, bool drop = false)#

Attempt to push a span into the buffer.

Parameters:
  • elem_span[in] The span to push data from.

  • drop[in] Whether or not to consider the span elements dropped if they can’t all be pushed.

Returns:

Whether or not the entire span was pushed. No elements are pushed otherwise.

inline Result push_n(const element_t *elem_array, std::size_t count, bool drop = false)#

Attempt to push an arbitrary number of elements into the buffer.

Parameters:
  • elem_array[in] The array to source count elements from.

  • count[in] The number of elements to attempt adding from elem_array.

  • drop[in] Whether or not to consider all count elements dropped if they can’t all be added.

Returns:

Whether or not all elements were added. This method only adds either count elements or none of them.

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

Attempt to push an array into the buffer. Allows making partial progress.

Template Parameters:

N – The size of elem_array.

Parameters:

elem_array[in] The array to push data from.

Returns:

The number of elements pushed.

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

Attempt to push a span into the buffer. Allows making partial progress.

Parameters:

elem_span[in] The span to push data from.

Returns:

The number of elements pushed.

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

Attempt to push an arbitrary number of elements into the buffer. Adds as many elements as possible (without blocking).

Parameters:
  • elem_array[in] Same as push_n.

  • count[in] Same as push_n.

Returns:

The number of elements successfully added to the buffer.

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

Push an array into the buffer and block until it’s added.

Template Parameters:

N – The size of elem_array.

Parameters:

elem_array[in] The array to push.

inline void push_n_blocking(const std::span<element_t> &elem_span)#

Push a span into the buffer and block until it’s added.

Parameters:

elem_array[in] The span to push.

inline void push_n_blocking(const element_t *elem_array, std::size_t count)#

Push elements into the buffer and block until they’re added.

Parameters:
  • elem_array[in] Same as push_n.

  • count[in] Same as push_n.