This commit is contained in:
J. Nick Koston 2025-07-06 18:03:53 -05:00
parent e355ce04f7
commit 48957aee8b
No known key found for this signature in database
2 changed files with 4 additions and 1 deletions

View File

@ -89,6 +89,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
if (delay == 0 && type == SchedulerItem::TIMEOUT) { if (delay == 0 && type == SchedulerItem::TIMEOUT) {
// Put in defer queue for guaranteed FIFO execution // Put in defer queue for guaranteed FIFO execution
LockGuard guard{this->lock_}; LockGuard guard{this->lock_};
this->cancel_deferred_item_locked_(component, is_static_string, name_ptr, type);
this->defer_queue_.push_back(std::move(item)); this->defer_queue_.push_back(std::move(item));
return; return;
} }
@ -434,7 +435,7 @@ size_t HOT Scheduler::cancel_deferred_item_locked_(Component *component, const c
SchedulerItem::Type type) { SchedulerItem::Type type) {
size_t cancelled_count = 0; size_t cancelled_count = 0;
for (auto &item : this->defer_queue_) { for (auto &item : this->defer_queue_) {
if (item->component != component || item->type != type || item->remove) { if (item->component != component || item->remove) {
continue; continue;
} }
const char *item_name = item->get_name(); const char *item_name = item->get_name();

View File

@ -157,9 +157,11 @@ class Scheduler {
// Cancel heap items (items_ and to_add_) // Cancel heap items (items_ and to_add_)
bool cancel_heap_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type); bool cancel_heap_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type);
#if !defined(USE_ESP8266) && !defined(USE_RP2040)
// Cancel deferred items (defer_queue_) // Cancel deferred items (defer_queue_)
bool cancel_deferred_item_(Component *component, bool is_static_string, const void *name_ptr, bool cancel_deferred_item_(Component *component, bool is_static_string, const void *name_ptr,
SchedulerItem::Type type); SchedulerItem::Type type);
#endif
private: private:
// Helper to execute a scheduler item // Helper to execute a scheduler item