Template Class PcBufferWriter#
Defined in File PcBufferWriter.h
Inheritance Relationships#
Derived Types#
public Coral::PcBuffer< tx_depth, element_t, sizeof(element_t) >(Template Class PcBuffer)public Coral::PcBuffer< rx_depth, element_t, sizeof(element_t) >(Template Class PcBuffer)public Coral::PcBuffer< tx_depth, std::byte, sizeof(std::byte) >(Template Class PcBuffer)public Coral::PcBuffer< rx_depth, std::byte, sizeof(std::byte) >(Template Class PcBuffer)public Coral::PcBuffer< depth, element_t, alignment, Lock >(Template Class PcBuffer)
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
countelements from.count – [in] The number of elements to attempt adding from
elem_array.drop – [in] Whether or not to consider all
countelements dropped if they can’t all be added.
- Returns:
Whether or not all elements were added. This method only adds either
countelements 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).
-
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.