[core] Inline fast path for enable_loop (#15392)

This commit is contained in:
J. Nick Koston
2026-04-02 11:28:12 -10:00
committed by GitHub
parent 4d0d3cc271
commit be3e0c27bf
2 changed files with 10 additions and 7 deletions
+4 -6
View File
@@ -294,12 +294,10 @@ void Component::disable_loop() {
App.disable_component_loop_(this); App.disable_component_loop_(this);
} }
} }
void Component::enable_loop() { void Component::enable_loop_slow_path_() {
if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_LOOP_DONE) { ESP_LOGVV(TAG, "%s loop enabled", LOG_STR_ARG(this->get_component_log_str()));
ESP_LOGVV(TAG, "%s loop enabled", LOG_STR_ARG(this->get_component_log_str())); this->set_component_state_(COMPONENT_STATE_LOOP);
this->set_component_state_(COMPONENT_STATE_LOOP); App.enable_component_loop_(this);
App.enable_component_loop_(this);
}
} }
void IRAM_ATTR HOT Component::enable_loop_soon_any_context() { void IRAM_ATTR HOT Component::enable_loop_soon_any_context() {
// This method is thread and ISR-safe because: // This method is thread and ISR-safe because:
+6 -1
View File
@@ -242,7 +242,10 @@ class Component {
* @note Components should call this->enable_loop() on themselves, not on other components. * @note Components should call this->enable_loop() on themselves, not on other components.
* This ensures the component's state is properly updated along with the loop partition. * This ensures the component's state is properly updated along with the loop partition.
*/ */
void enable_loop(); void enable_loop() {
if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_LOOP_DONE)
this->enable_loop_slow_path_();
}
/** Thread and ISR-safe version of enable_loop() that can be called from any context. /** Thread and ISR-safe version of enable_loop() that can be called from any context.
* *
@@ -344,6 +347,8 @@ class Component {
virtual void call_setup(); virtual void call_setup();
void call_dump_config_(); void call_dump_config_();
void enable_loop_slow_path_();
/// Helper to set component state (clears state bits and sets new state) /// Helper to set component state (clears state bits and sets new state)
inline void set_component_state_(uint8_t state) { inline void set_component_state_(uint8_t state) {
this->component_state_ &= ~COMPONENT_STATE_MASK; this->component_state_ &= ~COMPONENT_STATE_MASK;