HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Attributes
tt::wfree_fifo< T, SlotSize > Class Template Reference

#include <ttauri/wfree_fifo.hpp>

Data Structures

struct  slot_type
 

Public Types

using value_type = T
 

Public Member Functions

 wfree_fifo (wfree_fifo const &)=delete
 
 wfree_fifo (wfree_fifo &&)=delete
 
wfree_fifooperator= (wfree_fifo const &)=delete
 
wfree_fifooperator= (wfree_fifo &&)=delete
 
template<typename Operation >
bool take_one (Operation &&operation) noexcept
 Take one message from the fifo slot.
 
tt_no_inline void contended () noexcept
 
template<typename Message , typename... Args>
requires (sizeof(Message) <= slot_type::buffer_size)
tt_force_inline void emplace (Args &&...args) noexcept
 Create an message in-place on the fifo.
 
template<typename Message , typename... Args>
tt_force_inline void emplace (Args &&...args) noexcept
 Create an message in-place on the fifo.
 

Static Public Attributes

static constexpr size_t fifo_size = 65536
 
static constexpr size_t slot_size = SlotSize
 
static constexpr size_t num_slots = fifo_size / slot_size
 

Detailed Description

template<typename T, size_t SlotSize>
class tt::wfree_fifo< T, SlotSize >

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.

Template Parameters
TBase class of the value type stored in the ring buffer.
SlotSizeSize of each slot, must be power-of-two.

Member Function Documentation

◆ emplace() [1/2]

template<typename T , size_t SlotSize>
template<typename Message , typename... Args>
requires (sizeof(Message) <= slot_type::buffer_size)
tt_force_inline void tt::wfree_fifo< T, SlotSize >::emplace ( Args &&... args)
inlinenoexcept

Create an message in-place on the fifo.

Template Parameters
MessageMessage type derived from value_type to be stored in a free slot.
Parameters
argsThe arguments passed to the constructor of Message.

◆ emplace() [2/2]

template<typename T , size_t SlotSize>
template<typename Message , typename... Args>
tt_force_inline void tt::wfree_fifo< T, SlotSize >::emplace ( Args &&... args)
inlinenoexcept

Create an message in-place on the fifo.

Template Parameters
MessageMessage type derived from value_type to be stored in a free slot.
Parameters
argsThe arguments passed to the constructor of Message.

◆ take_one()

template<typename T , size_t SlotSize>
template<typename Operation >
bool tt::wfree_fifo< T, SlotSize >::take_one ( Operation && operation)
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.

Parameters
operationA void(value_type const &) which is called when a message is available.
Returns
True if a message was available in the fifo.

The documentation for this class was generated from the following file: