mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 10:57:46 +00:00
guard esp8266
This commit is contained in:
parent
71e06ea1b6
commit
0fc3f0e162
@ -81,6 +81,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
|||||||
item->callback = std::move(func);
|
item->callback = std::move(func);
|
||||||
item->remove = false;
|
item->remove = false;
|
||||||
|
|
||||||
|
#ifndef USE_ESP8266
|
||||||
// Special handling for defer() (delay = 0, type = TIMEOUT)
|
// Special handling for defer() (delay = 0, type = TIMEOUT)
|
||||||
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
|
||||||
@ -88,6 +89,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
|||||||
this->defer_queue_.push_back(std::move(item));
|
this->defer_queue_.push_back(std::move(item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto now = this->millis_();
|
const auto now = this->millis_();
|
||||||
|
|
||||||
@ -217,6 +219,7 @@ optional<uint32_t> HOT Scheduler::next_schedule_in() {
|
|||||||
return item->next_execution_ - now;
|
return item->next_execution_ - now;
|
||||||
}
|
}
|
||||||
void HOT Scheduler::call() {
|
void HOT Scheduler::call() {
|
||||||
|
#ifndef USE_ESP8266
|
||||||
// Process defer queue first to guarantee FIFO execution order for deferred items.
|
// Process defer queue first to guarantee FIFO execution order for deferred items.
|
||||||
// Previously, defer() used the heap which gave undefined order for equal timestamps,
|
// Previously, defer() used the heap which gave undefined order for equal timestamps,
|
||||||
// causing race conditions on multi-core systems (ESP32, RP2040, BK7200).
|
// causing race conditions on multi-core systems (ESP32, RP2040, BK7200).
|
||||||
@ -248,6 +251,7 @@ void HOT Scheduler::call() {
|
|||||||
this->execute_item_(item.get());
|
this->execute_item_(item.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto now = this->millis_();
|
const auto now = this->millis_();
|
||||||
this->process_to_add();
|
this->process_to_add();
|
||||||
@ -432,12 +436,14 @@ bool HOT Scheduler::cancel_item_common_(Component *component, bool is_static_str
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
// Check all containers for matching items
|
// Check all containers for matching items
|
||||||
|
#ifndef USE_ESP8266
|
||||||
for (auto &item : this->defer_queue_) {
|
for (auto &item : this->defer_queue_) {
|
||||||
if (this->matches_item_(item, component, name_cstr, type)) {
|
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||||
item->remove = true;
|
item->remove = true;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (auto &item : this->items_) {
|
for (auto &item : this->items_) {
|
||||||
if (this->matches_item_(item, component, name_cstr, type)) {
|
if (this->matches_item_(item, component, name_cstr, type)) {
|
||||||
|
@ -166,7 +166,9 @@ class Scheduler {
|
|||||||
Mutex lock_;
|
Mutex lock_;
|
||||||
std::vector<std::unique_ptr<SchedulerItem>> items_;
|
std::vector<std::unique_ptr<SchedulerItem>> items_;
|
||||||
std::vector<std::unique_ptr<SchedulerItem>> to_add_;
|
std::vector<std::unique_ptr<SchedulerItem>> to_add_;
|
||||||
|
#ifndef USE_ESP8266
|
||||||
std::deque<std::unique_ptr<SchedulerItem>> defer_queue_; // FIFO queue for defer() calls
|
std::deque<std::unique_ptr<SchedulerItem>> defer_queue_; // FIFO queue for defer() calls
|
||||||
|
#endif
|
||||||
uint32_t last_millis_{0};
|
uint32_t last_millis_{0};
|
||||||
uint16_t millis_major_{0};
|
uint16_t millis_major_{0};
|
||||||
uint32_t to_remove_{0};
|
uint32_t to_remove_{0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user