template<std::size_t MaxSinks, typename Channel = null_wait_channel>
class microfmt::log::fanout_log_sink< MaxSinks, Channel >
Fixed-capacity sink that forwards each record to up to MaxSinks advanced sinks ("pins"), applies back-pressure when one is full, and keeps thread-context writers in FIFO order. Nothing here busy-waits.
Two classes of writer:
- Priority writers (
meta.can_wait() clear: IRQ, NMI, ...) never queue and never sleep. They write straight to every pin, which overwrites its oldest data or drops. They take no fan-out lock at all, so a sleeping thread writer can never delay them.
- Thread writers (
meta.can_wait() set) take a ticket under the channel lock and sleep on the channel until it is their turn (strict arrival order, one writer at a time). The turn holder then, if any pin is full, sleeps up to set_wait_timeout_us for space and otherwise discards the record (counted in dropped). It writes outside the channel lock and hands the turn on, waking the queue.
Readers take only their pin's own lock; afterwards they call notify_space (thread context: it takes the channel lock) to wake the writers. Lock order: channel lock, then pin lock. Call notify_space after releasing the pin lock.
Pins must make log safe against concurrent priority writers (their own short lock). A priority writer may refill a pin after the turn holder saw space; the pin then drops that thread record (its can_wait is set).
Logger for advanced sinks. Derives from basic_logger, so the whole formatting/level/locking API is in...
Definition extended_logger.hpp:70
Fixed-capacity sink that forwards each record to up to MaxSinks advanced sinks ("pins"),...
Definition extended_sink.hpp:210
extended_log_sink as_sink(level lvl=level::trace) &noexcept RELOCO_LIFETIMEBOUND
Handle for use as a sink (e.g. by extended_logger).
Definition extended_sink.hpp:247
bool add_sink(extended_log_sink s) noexcept
Appends s; returns false when the table is full. Thread context only. Safe against concurrent writers...
Definition extended_sink.hpp:232
void notify_space() noexcept
Reader side: tells waiting writers that space may have been freed. Thread context.
Definition extended_sink.hpp:252
void set_wait_timeout_us(std::uint64_t us) noexcept
Longest a turn holder sleeps for space, per record.
Definition extended_sink.hpp:244
basic_logger< 4, 256 > logger
Definition logger.hpp:242
- Template Parameters
-
| MaxSinks | Capacity of the sink table. |
| Channel | Outer lock + sleep/wake primitive, see sync.hpp. |