mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	preen
This commit is contained in:
		| @@ -430,39 +430,6 @@ bool HOT Scheduler::cancel_item_(Component *component, bool is_static_string, co | ||||
|   return this->cancel_item_locked_(component, name_cstr, type); | ||||
| } | ||||
|  | ||||
| // Helper to mark heap items for cancellation and update to_remove_ count | ||||
| size_t HOT Scheduler::cancel_heap_item_locked_(Component *component, const char *name_cstr, SchedulerItem::Type type) { | ||||
|   size_t cancelled_count = 0; | ||||
|  | ||||
|   // 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) { | ||||
|       item->remove = true; | ||||
|       cancelled_count++; | ||||
|       this->to_remove_++;  // Track removals for heap items | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // 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) { | ||||
|       item->remove = true; | ||||
|       cancelled_count++; | ||||
|       // Don't track removals for to_add_ items | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   return cancelled_count; | ||||
| } | ||||
|  | ||||
| // Helper to cancel items by name - must be called with lock held | ||||
| bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_cstr, SchedulerItem::Type type) { | ||||
|   size_t total_cancelled = 0; | ||||
| @@ -481,7 +448,32 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c | ||||
|     } | ||||
|   } | ||||
| #endif | ||||
|   total_cancelled += this->cancel_heap_item_locked_(component, name_cstr, type); | ||||
|  | ||||
|   // 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) { | ||||
|       item->remove = true; | ||||
|       total_cancelled++; | ||||
|       this->to_remove_++;  // Track removals for heap items | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // 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) { | ||||
|       item->remove = true; | ||||
|       total_cancelled++; | ||||
|       // Don't track removals for to_add_ items | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   return total_cancelled > 0; | ||||
| } | ||||
|   | ||||
| @@ -140,14 +140,6 @@ class Scheduler { | ||||
|   // Helper to cancel items by name - must be called with lock held | ||||
|   bool cancel_item_locked_(Component *component, const char *name, SchedulerItem::Type type); | ||||
|  | ||||
| #if !defined(USE_ESP8266) && !defined(USE_RP2040) | ||||
|   // Helper to mark deferred items for cancellation (no to_remove_ tracking needed) | ||||
|   size_t cancel_deferred_item_locked_(Component *component, const char *name_cstr, SchedulerItem::Type type); | ||||
| #endif | ||||
|  | ||||
|   // Helper to mark heap items for cancellation and update to_remove_ count | ||||
|   size_t cancel_heap_item_locked_(Component *component, const char *name_cstr, SchedulerItem::Type type); | ||||
|  | ||||
|   uint64_t millis_(); | ||||
|   void cleanup_(); | ||||
|   void pop_raw_(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user