[core] Freshen loop_component_start_time_ before scheduler dispatch

This commit is contained in:
J. Nick Koston
2026-04-27 15:28:23 -05:00
parent 7198c912c7
commit 95977bcccb
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -103,6 +103,12 @@ class Application {
void set_current_component(Component *component) { this->current_component_ = component; }
Component *get_current_component() { return this->current_component_; }
/// Update the cached loop component start time. Used by the scheduler before
/// dispatching a queued callback so callers reading
/// get_loop_component_start_time() inside the callback observe a fresh value
/// instead of one inherited from the prior loop iteration's last component.
void set_loop_component_start_time(uint32_t now) { this->loop_component_start_time_ = now; }
// Entity register methods (generated from entity_types.h).
// Each entity type gets two overloads:
// - register_<entity>(obj) — bare push_back
+5
View File
@@ -772,6 +772,11 @@ Scheduler::SchedulerItem *HOT Scheduler::pop_raw_locked_() {
// Helper to execute a scheduler item
uint32_t HOT Scheduler::execute_item_(SchedulerItem *item, uint32_t now) {
App.set_current_component(item->component);
// Freshen the cached loop component start time so callbacks reading
// App.get_loop_component_start_time() observe the dispatch time of this
// item rather than a stale value from the prior loop iteration's last
// component phase.
App.set_loop_component_start_time(now);
WarnIfComponentBlockingGuard guard{item->component, now};
item->callback();
uint32_t end = guard.finish();