mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 09:57:47 +00:00
tweak
This commit is contained in:
parent
ba8f3d3f63
commit
0900fd3cea
@ -440,11 +440,7 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c
|
||||
// Only check defer queue for timeouts (intervals never go there)
|
||||
if (type == SchedulerItem::TIMEOUT) {
|
||||
for (auto &item : this->defer_queue_) {
|
||||
if (item->component != component || item->remove) {
|
||||
continue;
|
||||
}
|
||||
const char *item_name = item->get_name();
|
||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
||||
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||
item->remove = true;
|
||||
total_cancelled++;
|
||||
}
|
||||
@ -457,11 +453,7 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c
|
||||
|
||||
// Cancel items in the main heap
|
||||
for (auto &item : this->items_) {
|
||||
if (item->component != component || item->type != type || item->remove) {
|
||||
continue;
|
||||
}
|
||||
const char *item_name = item->get_name();
|
||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
||||
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||
item->remove = true;
|
||||
total_cancelled++;
|
||||
this->to_remove_++; // Track removals for heap items
|
||||
@ -470,11 +462,7 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c
|
||||
|
||||
// Cancel items in to_add_
|
||||
for (auto &item : this->to_add_) {
|
||||
if (item->component != component || item->type != type || item->remove) {
|
||||
continue;
|
||||
}
|
||||
const char *item_name = item->get_name();
|
||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
||||
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||
item->remove = true;
|
||||
total_cancelled++;
|
||||
// Don't track removals for to_add_ items
|
||||
|
@ -147,6 +147,17 @@ class Scheduler {
|
||||
|
||||
// Common implementation for cancel operations
|
||||
bool cancel_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type);
|
||||
|
||||
// Helper function to check if item matches criteria for cancellation
|
||||
bool HOT matches_item_(const std::unique_ptr<SchedulerItem> &item, Component *component, const char *name_cstr,
|
||||
SchedulerItem::Type type) {
|
||||
if (item->component != component || item->type != type || item->remove) {
|
||||
return false;
|
||||
}
|
||||
const char *item_name = item->get_name();
|
||||
return item_name != nullptr && strcmp(name_cstr, item_name) == 0;
|
||||
}
|
||||
|
||||
// Helper to execute a scheduler item
|
||||
void execute_item_(SchedulerItem *item);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user