FastLED 3.9.15
Loading...
Searching...
No Matches

◆ flush()

void fl::AsyncLogger::flush ( )

Definition at line 67 of file async_logger.cpp.hpp.

67 {
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}
AsyncLogQueue< 128, 4096 > mQueue
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT
void print(const char *str)
void println(const char *str) FL_NOEXCEPT

References fl::memcpy(), fl::min(), mQueue, offset(), fl::print(), and fl::println().

Referenced by ~AsyncLogger().

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