mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 02:47:47 +00:00
Merge branch 'heap_scheduler_stress_component' into integration
This commit is contained in:
commit
4ea6f23d9e
@ -398,7 +398,9 @@ void HOT Scheduler::cleanup_() {
|
|||||||
// Reading to_remove_ without lock is safe because:
|
// Reading to_remove_ without lock is safe because:
|
||||||
// 1. We only call this from the main thread during call()
|
// 1. We only call this from the main thread during call()
|
||||||
// 2. If it's 0, there's definitely nothing to cleanup
|
// 2. If it's 0, there's definitely nothing to cleanup
|
||||||
// 3. If it becomes non-zero after we check, cleanup will happen next time
|
// 3. If it becomes non-zero after we check, cleanup will happen on the next loop iteration
|
||||||
|
// 4. Not all platforms support atomics, so we accept this race in favor of performance
|
||||||
|
// 5. The worst case is a one-loop-iteration delay in cleanup, which is harmless
|
||||||
if (this->to_remove_ == 0)
|
if (this->to_remove_ == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -163,7 +163,10 @@ class Scheduler {
|
|||||||
if (item_name == nullptr) {
|
if (item_name == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Fast path: if pointers are equal (common with string deduplication)
|
// Fast path: if pointers are equal
|
||||||
|
// This is effective because the core ESPHome codebase uses static strings (const char*)
|
||||||
|
// for component names. The std::string overloads exist only for compatibility with
|
||||||
|
// external components, but are rarely used in practice.
|
||||||
if (item_name == name_cstr) {
|
if (item_name == name_cstr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user