mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	cleanup
This commit is contained in:
		| @@ -93,7 +93,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type | |||||||
|   if (delay == SCHEDULER_DONT_RUN) { |   if (delay == SCHEDULER_DONT_RUN) { | ||||||
|     // Still need to cancel existing timer if name is not empty |     // Still need to cancel existing timer if name is not empty | ||||||
|     if (name_cstr != nullptr && name_cstr[0] != '\0') { |     if (name_cstr != nullptr && name_cstr[0] != '\0') { | ||||||
|       this->cancel_item_(component, name_cstr, type); |       this->cancel_item_(component, is_static_string, name_ptr, type); | ||||||
|     } |     } | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
| @@ -157,10 +157,10 @@ void HOT Scheduler::set_timeout(Component *component, const std::string &name, u | |||||||
|   this->set_timer_common_(component, SchedulerItem::TIMEOUT, false, &name, timeout, std::move(func)); |   this->set_timer_common_(component, SchedulerItem::TIMEOUT, false, &name, timeout, std::move(func)); | ||||||
| } | } | ||||||
| bool HOT Scheduler::cancel_timeout(Component *component, const std::string &name) { | bool HOT Scheduler::cancel_timeout(Component *component, const std::string &name) { | ||||||
|   return this->cancel_item_(component, name, SchedulerItem::TIMEOUT); |   return this->cancel_item_(component, false, &name, SchedulerItem::TIMEOUT); | ||||||
| } | } | ||||||
| bool HOT Scheduler::cancel_timeout(Component *component, const char *name) { | bool HOT Scheduler::cancel_timeout(Component *component, const char *name) { | ||||||
|   return this->cancel_item_(component, name, SchedulerItem::TIMEOUT); |   return this->cancel_item_(component, true, name, SchedulerItem::TIMEOUT); | ||||||
| } | } | ||||||
| void HOT Scheduler::set_interval(Component *component, const std::string &name, uint32_t interval, | void HOT Scheduler::set_interval(Component *component, const std::string &name, uint32_t interval, | ||||||
|                                  std::function<void()> func) { |                                  std::function<void()> func) { | ||||||
| @@ -172,10 +172,10 @@ void HOT Scheduler::set_interval(Component *component, const char *name, uint32_ | |||||||
|   this->set_timer_common_(component, SchedulerItem::INTERVAL, true, name, interval, std::move(func)); |   this->set_timer_common_(component, SchedulerItem::INTERVAL, true, name, interval, std::move(func)); | ||||||
| } | } | ||||||
| bool HOT Scheduler::cancel_interval(Component *component, const std::string &name) { | bool HOT Scheduler::cancel_interval(Component *component, const std::string &name) { | ||||||
|   return this->cancel_item_(component, name, SchedulerItem::INTERVAL); |   return this->cancel_item_(component, false, &name, SchedulerItem::INTERVAL); | ||||||
| } | } | ||||||
| bool HOT Scheduler::cancel_interval(Component *component, const char *name) { | bool HOT Scheduler::cancel_interval(Component *component, const char *name) { | ||||||
|   return this->cancel_item_(component, name, SchedulerItem::INTERVAL); |   return this->cancel_item_(component, true, name, SchedulerItem::INTERVAL); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct RetryArgs { | struct RetryArgs { | ||||||
| @@ -392,7 +392,7 @@ void HOT Scheduler::pop_raw_() { | |||||||
|   this->items_.pop_back(); |   this->items_.pop_back(); | ||||||
| } | } | ||||||
| // Common implementation for cancel operations | // Common implementation for cancel operations | ||||||
| bool HOT Scheduler::cancel_item_common_(Component *component, bool is_static_string, const void *name_ptr, | bool HOT Scheduler::cancel_item_(Component *component, bool is_static_string, const void *name_ptr, | ||||||
|                                  SchedulerItem::Type type) { |                                  SchedulerItem::Type type) { | ||||||
|   // Get the name as const char* |   // Get the name as const char* | ||||||
|   const char *name_cstr = |   const char *name_cstr = | ||||||
| @@ -407,14 +407,6 @@ bool HOT Scheduler::cancel_item_common_(Component *component, bool is_static_str | |||||||
|   return this->cancel_item_locked_(component, name_cstr, type); |   return this->cancel_item_locked_(component, name_cstr, type); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, Scheduler::SchedulerItem::Type type) { |  | ||||||
|   return this->cancel_item_common_(component, false, &name, type); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bool HOT Scheduler::cancel_item_(Component *component, const char *name, SchedulerItem::Type type) { |  | ||||||
|   return this->cancel_item_common_(component, true, name, type); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| uint64_t Scheduler::millis_() { | uint64_t Scheduler::millis_() { | ||||||
|   // Get the current 32-bit millis value |   // Get the current 32-bit millis value | ||||||
|   const uint32_t now = millis(); |   const uint32_t now = millis(); | ||||||
|   | |||||||
| @@ -143,10 +143,7 @@ class Scheduler { | |||||||
|   void cleanup_(); |   void cleanup_(); | ||||||
|   void pop_raw_(); |   void pop_raw_(); | ||||||
|   // Common implementation for cancel operations |   // Common implementation for cancel operations | ||||||
|   bool cancel_item_common_(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); | ||||||
|  |  | ||||||
|   bool cancel_item_(Component *component, const std::string &name, SchedulerItem::Type type); |  | ||||||
|   bool cancel_item_(Component *component, const char *name, SchedulerItem::Type type); |  | ||||||
|  |  | ||||||
|   bool empty_() { |   bool empty_() { | ||||||
|     this->cleanup_(); |     this->cleanup_(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user