MCPcopy Create free account
hub / github.com/FastLED/FastLED / flush

Method flush

src/fl/log/async_logger.cpp.hpp:67–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void AsyncLogger::flush() {
68 const char* msg;
69 fl::u16 len;
70
71 // 256-byte stack buffer - handles most messages in a single chunk
72 // Avoids heap allocation entirely by chunking long messages
73 char buffer[256];
74
75 while (mQueue.tryPop(&msg, &len)) {
76 fl::u16 offset = 0;
77
78 // Process message in chunks to avoid heap allocation
79 while (offset < len) {
80 fl::u16 chunk_size = min(len - offset, static_cast<fl::u16>(sizeof(buffer) - 1));
81 fl::memcpy(buffer, msg + offset, chunk_size);
82 buffer[chunk_size] = '\0'; // Null-terminate
83
84 offset += chunk_size;
85
86 if (offset >= len) {
87 // Last chunk or whole message - use println (adds newline)
88 fl::println(buffer);
89 } else {
90 // Not last chunk - use print (no newline)
91 fl::print(buffer);
92 }
93 }
94
95 mQueue.commit();
96 }
97}
98
99fl::size AsyncLogger::size() const {
100 return mQueue.size();

Callers

nothing calls this directly

Calls 5

tryPopMethod · 0.80
commitMethod · 0.80
memcpyFunction · 0.50
printlnFunction · 0.50
printFunction · 0.50

Tested by

no test coverage detected