mirror of
https://github.com/esphome/esphome.git
synced 2026-03-03 19:28:20 -07:00
Don't allocate Mutex on single-threaded platforms
On ESPHOME_THREAD_SINGLE (ESP8266), the lock is never used. Guarding it avoids the static local guard variable overhead (8 bytes RAM + init check on every call). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,9 @@ static constexpr uint32_t HALF_MAX_UINT32 = std::numeric_limits<uint32_t>::max()
|
||||
|
||||
uint64_t Millis64Impl::compute(uint32_t now) {
|
||||
// State variables for rollover tracking - static to persist across calls
|
||||
#ifndef ESPHOME_THREAD_SINGLE
|
||||
static Mutex lock;
|
||||
#endif
|
||||
#ifdef ESPHOME_THREAD_MULTI_ATOMICS
|
||||
/*
|
||||
* Multi-threaded platforms with atomic support: last_millis needs atomic for lock-free updates.
|
||||
|
||||
Reference in New Issue
Block a user