mirror of
https://github.com/esphome/esphome.git
synced 2025-08-05 18:07: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)
|
// Only check defer queue for timeouts (intervals never go there)
|
||||||
if (type == SchedulerItem::TIMEOUT) {
|
if (type == SchedulerItem::TIMEOUT) {
|
||||||
for (auto &item : this->defer_queue_) {
|
for (auto &item : this->defer_queue_) {
|
||||||
if (item->component != component || item->remove) {
|
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const char *item_name = item->get_name();
|
|
||||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
|
||||||
item->remove = true;
|
item->remove = true;
|
||||||
total_cancelled++;
|
total_cancelled++;
|
||||||
}
|
}
|
||||||
@ -457,11 +453,7 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c
|
|||||||
|
|
||||||
// Cancel items in the main heap
|
// Cancel items in the main heap
|
||||||
for (auto &item : this->items_) {
|
for (auto &item : this->items_) {
|
||||||
if (item->component != component || item->type != type || item->remove) {
|
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const char *item_name = item->get_name();
|
|
||||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
|
||||||
item->remove = true;
|
item->remove = true;
|
||||||
total_cancelled++;
|
total_cancelled++;
|
||||||
this->to_remove_++; // Track removals for heap items
|
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_
|
// Cancel items in to_add_
|
||||||
for (auto &item : this->to_add_) {
|
for (auto &item : this->to_add_) {
|
||||||
if (item->component != component || item->type != type || item->remove) {
|
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const char *item_name = item->get_name();
|
|
||||||
if (item_name != nullptr && strcmp(name_cstr, item_name) == 0) {
|
|
||||||
item->remove = true;
|
item->remove = true;
|
||||||
total_cancelled++;
|
total_cancelled++;
|
||||||
// Don't track removals for to_add_ items
|
// Don't track removals for to_add_ items
|
||||||
|
@ -147,6 +147,17 @@ class Scheduler {
|
|||||||
|
|
||||||
// Common implementation for cancel operations
|
// Common implementation for cancel operations
|
||||||
bool cancel_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type);
|
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
|
// Helper to execute a scheduler item
|
||||||
void execute_item_(SchedulerItem *item);
|
void execute_item_(SchedulerItem *item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user