MayaFlux 1.0.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 111 of file Archivist.cpp.

112 {
113 while (auto entry = m_rt_ring_buffer.pop()) {
114 if (m_sinks.empty()) {
115 write_to_console(*entry);
116 } else {
117 write_to_sinks(*entry);
118 }
119 }
120
121 while (auto entry = m_ring_buffer.pop()) {
122 if (m_sinks.empty()) {
123 write_to_console(*entry);
124 } else {
125 write_to_sinks(*entry);
126 }
127 }
128
129 const auto dropped = m_dropped_messages.exchange(0, std::memory_order_acq_rel);
130 if (dropped > 0) {
131 std::cout << "[MayaFlux::Journal] WARNING: Dropped "
132 << dropped << " log messages (buffer full)\n";
133 }
134 }
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: