make more readable

This commit is contained in:
J. Nick Koston 2025-07-19 10:38:28 -10:00
parent a5f5af9596
commit 58696961bd
No known key found for this signature in database

View File

@ -511,15 +511,10 @@ uint64_t Scheduler::millis_64_(uint32_t now) {
#ifdef ESPHOME_SINGLE_CORE
// This is the single core implementation.
//
// The implementation handles the 32-bit rollover (every 49.7 days) by:
// 1. Using a lock when detecting rollover to ensure atomic update
// 2. Restricting normal updates to forward movement within the same epoch
// This prevents race conditions at the rollover boundary without requiring
// 64-bit atomics or locking on every call.
// Single-core platforms have no concurrency, so this is a simple implementation
// that just tracks 32-bit rollover (every 49.7 days) without any locking or atomics.
uint16_t major = this->millis_major_;
// Single-core platforms: No atomics needed
uint32_t last = this->last_millis_;
// Check for rollover
@ -538,7 +533,6 @@ uint64_t Scheduler::millis_64_(uint32_t now) {
// Combine major (high 32 bits) and now (low 32 bits) into 64-bit time
return now + (static_cast<uint64_t>(major) << 32);
}
#endif // ESPHOME_SINGLE_CORE
#ifdef ESPHOME_MULTI_CORE_NO_ATOMICS
@ -652,7 +646,6 @@ for (;;) {
return now + (static_cast<uint64_t>(major) << 32);
}
#endif // ESPHOME_MULTI_CORE_ATOMICS
}
bool HOT Scheduler::SchedulerItem::cmp(const std::unique_ptr<SchedulerItem> &a,