mirror of
https://github.com/esphome/esphome.git
synced 2025-08-02 00:17:48 +00:00
make more readable
This commit is contained in:
parent
a5f5af9596
commit
58696961bd
@ -511,15 +511,10 @@ uint64_t Scheduler::millis_64_(uint32_t now) {
|
|||||||
#ifdef ESPHOME_SINGLE_CORE
|
#ifdef ESPHOME_SINGLE_CORE
|
||||||
// This is the single core implementation.
|
// This is the single core implementation.
|
||||||
//
|
//
|
||||||
// The implementation handles the 32-bit rollover (every 49.7 days) by:
|
// Single-core platforms have no concurrency, so this is a simple implementation
|
||||||
// 1. Using a lock when detecting rollover to ensure atomic update
|
// that just tracks 32-bit rollover (every 49.7 days) without any locking or atomics.
|
||||||
// 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.
|
|
||||||
|
|
||||||
uint16_t major = this->millis_major_;
|
uint16_t major = this->millis_major_;
|
||||||
|
|
||||||
// Single-core platforms: No atomics needed
|
|
||||||
uint32_t last = this->last_millis_;
|
uint32_t last = this->last_millis_;
|
||||||
|
|
||||||
// Check for rollover
|
// 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
|
// Combine major (high 32 bits) and now (low 32 bits) into 64-bit time
|
||||||
return now + (static_cast<uint64_t>(major) << 32);
|
return now + (static_cast<uint64_t>(major) << 32);
|
||||||
}
|
|
||||||
#endif // ESPHOME_SINGLE_CORE
|
#endif // ESPHOME_SINGLE_CORE
|
||||||
|
|
||||||
#ifdef ESPHOME_MULTI_CORE_NO_ATOMICS
|
#ifdef ESPHOME_MULTI_CORE_NO_ATOMICS
|
||||||
@ -652,7 +646,6 @@ for (;;) {
|
|||||||
return now + (static_cast<uint64_t>(major) << 32);
|
return now + (static_cast<uint64_t>(major) << 32);
|
||||||
}
|
}
|
||||||
#endif // ESPHOME_MULTI_CORE_ATOMICS
|
#endif // ESPHOME_MULTI_CORE_ATOMICS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HOT Scheduler::SchedulerItem::cmp(const std::unique_ptr<SchedulerItem> &a,
|
bool HOT Scheduler::SchedulerItem::cmp(const std::unique_ptr<SchedulerItem> &a,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user