|
HikoGUI
A low latency retained GUI
|
#include <hikogui/wfree_fifo.hpp>
Public Types | |
| using | value_type = T |
| using | slot_type = polymorphic_optional<value_type, SlotSize, SlotSize> |
Public Member Functions | |
| wfree_fifo (wfree_fifo const &)=delete | |
| wfree_fifo (wfree_fifo &&)=delete | |
| wfree_fifo & | operator= (wfree_fifo const &)=delete |
| wfree_fifo & | operator= (wfree_fifo &&)=delete |
| bool | empty () const noexcept |
| Check if fifo is empty. | |
| template<typename Func > | |
| auto | take_one (Func &&func) noexcept |
| Take one message from the fifo slot. | |
| template<typename Operation > | |
| void | take_all (Operation const &operation) noexcept |
| Take all message from the queue. | |
| template<typename Message , typename Func , typename... Args> | |
| hi_force_inline auto | emplace_and_invoke (Func &&func, Args &&...args) noexcept |
| Create an message in-place on the fifo. | |
| template<typename Func , typename Object > | |
| hi_force_inline auto | insert_and_invoke (Func &&func, Object &&object) noexcept |
| template<typename Message , typename... Args> | |
| hi_force_inline void | emplace (Args &&...args) noexcept |
| template<typename Object > | |
| hi_force_inline void | insert (Object &&object) noexcept |
Static Public Attributes | |
| static constexpr std::size_t | fifo_size = 65536 |
| static constexpr std::size_t | slot_size = SlotSize |
| static constexpr std::size_t | num_slots = fifo_size / slot_size |
A wait-free multiple-producer/single-consumer fifo designed for absolute performance.
Because of performance reasons the ring-buffer is 64kByte. Each slot in the ring buffer consists of a pointer and a byte buffer for storage.
The number of slots in the ring-buffer is dictated by the size of each slot and the ring-buffer size.
| T | Base class of the value type stored in the ring buffer. |
| SlotSize | Size of each slot, must be power-of-two. |
|
inlinenoexcept |
Create an message in-place on the fifo.
| Message | The message type derived from value_type to be stored in a free slot. |
| func | The function to invoke on the message created on the fifo. |
| args | The arguments passed to the constructor of Message. |
|
inlinenoexcept |
Check if fifo is empty.
|
inlinenoexcept |
Take all message from the queue.
Reads each message from the ring buffer and passes it to a call of operation. If no message are available this function returns without calling operation.
| operation | A void(value_type const &) which is called when a message is available. |
|
inlinenoexcept |
Take one message from the fifo slot.
Reads one message from the ring buffer and passes it to a call of operation. If no message is available this function returns without calling operation.
| func | The function to call with the value as argument if it exists. |