|
xentara-utils v2.1
The Xentara Utility Library
|
A lock-free single element buffer. More...
#include <xentara/utils/lockFree/SingleElementBuffer.hpp>
Inheritance diagram for xentara::utils::lockFree::SingleElementBuffer< Element >:Public Member Functions | |
| auto | push (const Element &value) -> void |
| Buffers a value. | |
| auto | push (Element &&value) -> void |
| Buffers a value. | |
| template<typename... Arguments> requires std::is_constructible_v<Element, Arguments &&...> | |
| auto | emplace (Arguments &&...arguments) -> void |
| Constructs a value within the buffer. | |
| template<typename ListElement , typename... Arguments> requires std::is_constructible_v<Element, std::initializer_list<ListElement>, Arguments &&...> | |
| auto | emplace (std::initializer_list< ListElement > list, Arguments &&... arguments) -> void |
| Constructs a value within the buffer using an initializer list. | |
| auto | pop () -> std::optional< Element > |
| Gets the buffered value and clears the buffer. | |
A lock-free single element buffer.
This type of buffer can hold exactly one element. It is typically used in a producer-consumer system where the consumer consumes values asynchronously.
| Element |
| auto xentara::utils::lockFree::SingleElementBuffer< Element >::emplace | ( | Arguments &&... | arguments | ) | -> void |
Constructs a value within the buffer.
Any value already in the buffer will be replaced.
| arguments | The arguments for the constructor of the element |
| auto xentara::utils::lockFree::SingleElementBuffer< Element >::emplace | ( | std::initializer_list< ListElement > | list, |
| Arguments &&... | arguments | ||
| ) | -> void |
Constructs a value within the buffer using an initializer list.
Any value already in the buffer will be replaced.
| list | An initializer list to pass as the first argument to the constructor of the element |
| arguments | The remaining arguments for the constructor of the element |
| auto xentara::utils::lockFree::SingleElementBuffer< Element >::pop | ( | ) | -> std::optional<Element> |
Gets the buffered value and clears the buffer.
| auto xentara::utils::lockFree::SingleElementBuffer< Element >::push | ( | const Element & | value | ) | -> void |
Buffers a value.
Any value already in the buffer will be replaced.
| value | The value to place in the buffer |
| auto xentara::utils::lockFree::SingleElementBuffer< Element >::push | ( | Element && | value | ) | -> void |
Buffers a value.
Any value already in the buffer will be replaced.
| value | The value to place in the buffer |