mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 01:19:45 +08:00
[core] Inline fast path for enable_loop (#15392)
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user