1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-11 15:52:20 +01:00
This commit is contained in:
J. Nick Koston
2025-06-15 18:58:32 -05:00
parent 711b0a291b
commit fd31afe09c
3 changed files with 7 additions and 7 deletions

View File

@@ -251,7 +251,7 @@ void Application::calculate_looping_components_() {
this->looping_components_active_end_ = this->looping_components_.size();
}
void Application::disable_component_loop(Component *component) {
void Application::disable_component_loop_(Component *component) {
// This method must be reentrant - components can disable themselves during their own loop() call
// Linear search to find component in active section
// Most configs have 10-30 looping components (30 is on the high end)
@@ -274,7 +274,7 @@ void Application::disable_component_loop(Component *component) {
}
}
void Application::enable_component_loop(Component *component) {
void Application::enable_component_loop_(Component *component) {
// This method must be reentrant - components can re-enable themselves during their own loop() call
// Single pass through all components to find and move if needed
// With typical 10-30 components, O(n) is faster than maintaining a map

View File

@@ -575,8 +575,8 @@ class Application {
// These methods are called by Component::disable_loop() and Component::enable_loop()
// Components should not call these directly - use this->disable_loop() or this->enable_loop()
// to ensure component state is properly updated along with the loop partition
void disable_component_loop(Component *component);
void enable_component_loop(Component *component);
void disable_component_loop_(Component *component);
void enable_component_loop_(Component *component);
void feed_wdt_arch_();

View File

@@ -145,20 +145,20 @@ void Component::mark_failed() {
this->component_state_ |= COMPONENT_STATE_FAILED;
this->status_set_error();
// Also remove from loop since failed components shouldn't loop
App.disable_component_loop(this);
App.disable_component_loop_(this);
}
void Component::disable_loop() {
ESP_LOGD(TAG, "%s loop disabled", this->get_component_source());
this->component_state_ &= ~COMPONENT_STATE_MASK;
this->component_state_ |= COMPONENT_STATE_LOOP_DONE;
App.disable_component_loop(this);
App.disable_component_loop_(this);
}
void Component::enable_loop() {
if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_LOOP_DONE) {
ESP_LOGD(TAG, "%s loop enabled", this->get_component_source());
this->component_state_ &= ~COMPONENT_STATE_MASK;
this->component_state_ |= COMPONENT_STATE_LOOP;
App.enable_component_loop(this);
App.enable_component_loop_(this);
}
}
void Component::reset_to_construction_state() {