Class thl::Logger::rt::DrainThread#

class DrainThread#

A thread that drains a Queue periodically.

Runs at thl::core::ThreadPriority::Low by default: below UI work, but not starved like a background class would be, so delivery latency stays bounded by the interval. The destructor stops the thread, joins it and drains what arrived after its last pass; it must not run on the drain thread itself (i.e. from inside a sink callback).

Public Functions

explicit DrainThread(Queue &queue)#

Starts the thread. queue must outlive this object.

DrainThread(Queue &queue, const Options &options)#
~DrainThread() noexcept#
DrainThread(const DrainThread&) = delete#
DrainThread &operator=(const DrainThread&) = delete#
DrainThread(DrainThread&&) = delete#
DrainThread &operator=(DrainThread&&) = delete#
bool is_running() const noexcept#
bool is_current_thread() const noexcept#

True when called from the drain thread itself.

void set_interval_ms(std::uint32_t interval_ms) noexcept#

Change the drain interval of the running thread.

struct Options#

Public Members

std::uint32_t m_interval_ms = 10#
thl::core::ThreadPriority m_priority = thl::core::ThreadPriority::Low#
const char *m_name = "thl-log-drain"#