mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 16:48:40 +00:00
Move millis_64() call inside non-defer path
defer() items go straight into defer_queue_ and never use a timestamp. Now that millis_64() has its own lock separate from the scheduler, the call no longer needs to happen before taking the scheduler lock. Move it inside the non-defer branch so defer() avoids the cost entirely. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6c8542026f
commit
c121d8dc2a
@@ -147,9 +147,6 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
||||
return;
|
||||
}
|
||||
|
||||
// Get fresh 64-bit timestamp BEFORE taking lock
|
||||
const uint64_t now_64 = millis_64();
|
||||
|
||||
// Take lock early to protect scheduler_item_pool_ access
|
||||
LockGuard guard{this->lock_};
|
||||
|
||||
@@ -176,6 +173,9 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
||||
} else
|
||||
#endif /* not ESPHOME_THREAD_SINGLE */
|
||||
{
|
||||
// Only non-defer items need a timestamp for scheduling
|
||||
const uint64_t now_64 = millis_64();
|
||||
|
||||
// Type-specific setup
|
||||
if (type == SchedulerItem::INTERVAL) {
|
||||
item->interval = delay;
|
||||
|
||||
Reference in New Issue
Block a user