1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-04 04:12:23 +01:00

[scheduler] Fix LibreTiny compilation error due to missing atomic operations (#9643)

This commit is contained in:
J. Nick Koston
2025-07-17 16:21:46 -10:00
committed by GitHub
parent 158a3b2835
commit a18ddd1169
2 changed files with 51 additions and 9 deletions

View File

@@ -4,7 +4,7 @@
#include <memory>
#include <cstring>
#include <deque>
#if !defined(USE_ESP8266) && !defined(USE_RP2040)
#if !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY)
#include <atomic>
#endif
@@ -211,11 +211,11 @@ class Scheduler {
// Both platforms save 40 bytes of RAM by excluding this
std::deque<std::unique_ptr<SchedulerItem>> defer_queue_; // FIFO queue for defer() calls
#endif
#if !defined(USE_ESP8266) && !defined(USE_RP2040)
// Multi-threaded platforms: last_millis_ needs atomic for lock-free updates
#if !defined(USE_ESP8266) && !defined(USE_RP2040) && !defined(USE_LIBRETINY)
// Multi-threaded platforms with atomic support: last_millis_ needs atomic for lock-free updates
std::atomic<uint32_t> last_millis_{0};
#else
// Single-threaded platforms: no atomics needed
// Platforms without atomic support or single-threaded platforms
uint32_t last_millis_{0};
#endif
// millis_major_ is protected by lock when incrementing, volatile ensures