[logger] Enable loop disable optimization for LibreTiny task log buffer

This commit is contained in:
J. Nick Koston
2026-01-07 23:34:39 -10:00
parent e301b8d0e0
commit d402b0c391
2 changed files with 5 additions and 5 deletions

View File

@@ -197,8 +197,8 @@ void Logger::init_log_buffer(size_t total_buffer_size) {
this->log_buffer_ = esphome::make_unique<logger::TaskLogBufferLibreTiny>(total_buffer_size);
#endif
#ifdef USE_ESP32
// Start with loop disabled when using task buffer (unless using USB CDC)
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
// Start with loop disabled when using task buffer (unless using USB CDC on ESP32)
// The loop will be enabled automatically when messages arrive
this->disable_loop_when_buffer_empty_();
#endif
@@ -247,7 +247,7 @@ void Logger::process_messages_() {
}
#endif
}
#ifdef USE_ESP32
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
else {
// No messages to process, disable loop if appropriate
// This reduces overhead when there's no async logging activity

View File

@@ -609,8 +609,8 @@ class Logger : public Component {
this->write_body_to_buffer_(ESPHOME_LOG_RESET_COLOR, RESET_COLOR_LEN, buffer, buffer_at, buffer_size);
}
#ifdef USE_ESP32
// Disable loop when task buffer is empty (with USB CDC check)
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
// Disable loop when task buffer is empty (with USB CDC check on ESP32)
inline void disable_loop_when_buffer_empty_() {
// Thread safety note: This is safe even if another task calls enable_loop_soon_any_context()
// concurrently. If that happens between our check and disable_loop(), the enable request