Contents

class

SushiDSP::AsyncLogSink

Queues each line and lets a worker thread write it to another sink, in order.

Declared in
include/SushiDSP/log/AsyncLogSink.hpp
Inherits
SushiDSP::ILogSink

write() neither blocks nor allocates: a line that finds the queue full is dropped and counted, and the worker reports the count downstream. See include/SushiDSP/README.md.

Public member functions

AsyncLogSink(std::shared_ptr< ILogSink > downstream, std::size_t queue_capacity)

Allocates the queue and starts the worker thread.

Parameters

downstream

Receives every line on the worker thread; must not be null.

queue_capacity

Lines the queue holds; rounded up to a power of two.

~AsyncLogSink() override

Writes every queued line downstream, flushes it and joins the worker.

AsyncLogSink(const AsyncLogSink &)=delete
AsyncLogSink & operator=(const AsyncLogSink &)=delete
AsyncLogSink(AsyncLogSink &&)=delete
AsyncLogSink & operator=(AsyncLogSink &&)=delete
virtual void write(const LogRecord &record) noexcept override

Queues one line, or drops and counts it when the queue is full.

virtual void flush() noexcept override

Blocks until every line queued before the call is written and flushed downstream.

Precondition

The caller is not the worker thread.

std::uint64_t dropped_count() const noexcept

Returns how many lines a full queue has refused.