MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ drain_ring_buffer()

void MayaFlux::Journal::Archivist::Impl::drain_ring_buffer ( )
inline

Drain all pending ring buffer entries to sinks or console.

Lock-free. Safe to call from any thread. The worker calls this on its normal cadence; error() and fatal() call it synchronously before propagating exceptions or aborting to guarantee visibility.

Definition at line 109 of file Archivist.cpp.

110 {
111 while (auto entry = m_rt_ring_buffer.pop()) {
112 if (m_sinks.empty()) {
113 write_to_console(*entry);
114 } else {
115 write_to_sinks(*entry);
116 }
117 }
118
119 while (auto entry = m_ring_buffer.pop()) {
120 if (m_sinks.empty()) {
121 write_to_console(*entry);
122 } else {
123 write_to_sinks(*entry);
124 }
125 }
126
127 const auto dropped = m_dropped_messages.exchange(0, std::memory_order_acq_rel);
128 if (dropped > 0) {
129 std::cout << "[MayaFlux::Journal] WARNING: Dropped "
130 << dropped << " log messages (buffer full)\n";
131 }
132 }
void write_to_sinks(const RealtimeEntry &entry)
Memory::MPSCQueue< RealtimeEntry, RT_RING_BUFFER_SIZE > m_rt_ring_buffer
static void write_to_console(const RealtimeEntry &entry)
Memory::LockFreeQueue< RealtimeEntry, RING_BUFFER_SIZE > m_ring_buffer
std::vector< std::unique_ptr< Sink > > m_sinks
std::atomic< uint64_t > m_dropped_messages

References m_dropped_messages, m_ring_buffer, m_rt_ring_buffer, m_sinks, write_to_console(), and write_to_sinks().

Referenced by shutdown(), and worker_loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: