A classic FIFO buffer implementation with different strategies F.
More...
#include <fifo_buffer.hpp>
|
| | FifoBuffer ()=default |
| | FifoBuffer (const size_t capacity) |
| | Constructs a queue with a given number of elements.
|
| | FifoBuffer (const FifoBuffer &other)=delete |
| FifoBuffer & | operator= (const FifoBuffer &other)=delete |
| | FifoBuffer (FifoBuffer &&other) noexcept=delete |
| FifoBuffer & | operator= (FifoBuffer &&other) noexcept=delete |
| bool | push (T value) |
| | Pushes a value to the buffer.
|
| std::optional< T > | pop () |
| | Pops a value from the buffer.
|
| void | pop_all () |
| | Convenience function to pop all available data.
|
| template<typename U = T, std::enable_if_t< std::is_trivially_copyable_v< U >, int > = 0> |
| bool | write (const T *src, const size_t number_of_elements) |
| | Writes data to the buffer.
|
| template<typename U = T, std::enable_if_t< std::is_trivially_copyable_v< U >, int > = 0> |
| bool | read (T *dst, const size_t number_of_elements) |
| | Reads data from the buffer.
|
| void | resize (size_t size) |
| | Resizes this buffer, clearing existing data.
|
| void | reset () |
| | Clears the buffer.
|
| size_t | size () |
template<class T, class F>
class rav::FifoBuffer< T, F >
A classic FIFO buffer implementation with different strategies F.
Definition at line 39 of file fifo_buffer.hpp.
◆ FifoBuffer() [1/4]
template<class T, class F>
◆ FifoBuffer() [2/4]
template<class T, class F>
Constructs a queue with a given number of elements.
- Parameters
-
| capacity | The number of elements the queue can hold. |
Definition at line 47 of file fifo_buffer.hpp.
◆ FifoBuffer() [3/4]
template<class T, class F>
◆ FifoBuffer() [4/4]
template<class T, class F>
◆ operator=() [1/2]
template<class T, class F>
◆ operator=() [2/2]
template<class T, class F>
◆ pop()
template<class T, class F>
Pops a value from the buffer.
- Returns
- The value that was popped, or std::nullopt if the buffer is empty.
Definition at line 75 of file fifo_buffer.hpp.
◆ pop_all()
template<class T, class F>
Convenience function to pop all available data.
Thread safe when called from the consumer thread.
Definition at line 88 of file fifo_buffer.hpp.
◆ push()
template<class T, class F>
Pushes a value to the buffer.
- Parameters
-
- Returns
- True if the value was pushed, false if the buffer is full.
Definition at line 62 of file fifo_buffer.hpp.
◆ read()
template<class T, class F>
template<typename U = T, std::enable_if_t< std::is_trivially_copyable_v< U >, int > = 0>
| bool rav::FifoBuffer< T, F >::read |
( |
T * | dst, |
|
|
const size_t | number_of_elements ) |
|
inlinenodiscard |
Reads data from the buffer.
- Parameters
-
| dst | The destination to write the data to. |
| number_of_elements | The number of elements to read (not bytes). |
- Returns
- True if reading was successful, false if there was not enough data to read.
Definition at line 124 of file fifo_buffer.hpp.
◆ reset()
template<class T, class F>
◆ resize()
template<class T, class F>
Resizes this buffer, clearing existing data.
- Parameters
-
| size | The new capacity of the buffer. |
Definition at line 144 of file fifo_buffer.hpp.
◆ size()
template<class T, class F>
- Returns
- The number of elements in the buffer.
Definition at line 160 of file fifo_buffer.hpp.
◆ write()
template<class T, class F>
template<typename U = T, std::enable_if_t< std::is_trivially_copyable_v< U >, int > = 0>
| bool rav::FifoBuffer< T, F >::write |
( |
const T * | src, |
|
|
const size_t | number_of_elements ) |
|
inlinenodiscard |
Writes data to the buffer.
- Parameters
-
| src | The source data to write to the buffer. |
| number_of_elements | The number of elements to write (not bytes). |
- Returns
- True if writing was successful, false if there was not enough space to write all data.
Definition at line 101 of file fifo_buffer.hpp.
The documentation for this class was generated from the following file: