Loading...
Searching...
No Matches
oscr::message_ring< T, N > Struct Template Reference
Inheritance diagram for oscr::message_ring< T, N >:
oscr::drain_request

Detailed Description

template<typename T, std::size_t N = 16>
struct oscr::message_ring< T, N >

Processor to UI messages too large to travel inside an execution command: a fixed ring with one writing thread (the processor's) and one reading thread (the UI). Nothing allocates once it is built; the reader moves the messages out, so what they own is freed on the UI thread.

When the ring is full, push() drops the message and returns false: the UI misses that update and catches up with the next message that fits.

Public Member Functions

bool push (T &&msg) noexcept(std::is_nothrow_move_assignable_v< T >)
 
template<typename F >
int drain (F &&f)
 UI thread: calls f with every message written since the last call.
 
std::size_t dropped () const noexcept
 
- Public Member Functions inherited from oscr::drain_request
bool request () noexcept
 
void cancel () noexcept
 
void clear () noexcept
 
void park () noexcept
 Writer's thread: the wake-up could not be sent.
 
bool unpark () noexcept
 Writer's thread: whether a wake-up was parked since the last call.
 

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