mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 10:57:46 +00:00
Update scheduler.cpp
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
b7fca5488a
commit
0cda83d29c
@ -234,10 +234,11 @@ 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();
|
{
|
||||||
|
LockGuard lock(this->lock_);
|
||||||
auto item = std::move(this->defer_queue_.front());
|
auto item = std::move(this->defer_queue_.front());
|
||||||
this->defer_queue_.pop_front();
|
this->defer_queue_.pop_front();
|
||||||
this->lock_.unlock();
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user