mirror of
https://github.com/esphome/esphome.git
synced 2025-08-06 18:37:47 +00:00
Merge branch 'reduce_main_loop' into integration
This commit is contained in:
commit
94b6344820
@ -234,10 +234,12 @@ void HOT Scheduler::call() {
|
|||||||
// The outer check is done without a lock for performance. If the queue
|
// The outer check is done without a lock for performance. If the queue
|
||||||
// appears non-empty, we lock and process an item. We don't need to check
|
// appears non-empty, we lock and process an item. We don't need to check
|
||||||
// empty() again inside the lock because only this thread can remove items.
|
// empty() again inside the lock because only this thread can remove items.
|
||||||
this->lock_.lock();
|
std::unique_ptr<SchedulerItem> item;
|
||||||
auto item = std::move(this->defer_queue_.front());
|
{
|
||||||
this->defer_queue_.pop_front();
|
LockGuard lock(this->lock_);
|
||||||
this->lock_.unlock();
|
item = std::move(this->defer_queue_.front());
|
||||||
|
this->defer_queue_.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
// Execute callback without holding lock to prevent deadlocks
|
// Execute callback without holding lock to prevent deadlocks
|
||||||
// if the callback tries to call defer() again
|
// if the callback tries to call defer() again
|
||||||
|
@ -143,6 +143,7 @@ class Scheduler {
|
|||||||
// 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_common_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type);
|
||||||
|
|
||||||
|
private:
|
||||||
bool cancel_item_(Component *component, const std::string &name, 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 cancel_item_(Component *component, const char *name, SchedulerItem::Type type);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user