1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 14:43:51 +00:00

Lock scheduler items while modifying them (#4410)

* Cosmetic fixes to scheduler code

* Add generic Mutex API

* Lock scheduler items while modifying them

* Always defer MQTT callbacks on Arduino
This commit is contained in:
Oxan van Leeuwen
2023-02-26 19:43:08 +01:00
committed by GitHub
parent 1a9141877d
commit 86c0e6114f
5 changed files with 100 additions and 12 deletions

View File

@@ -1,9 +1,11 @@
#pragma once
#include "esphome/core/component.h"
#include <vector>
#include <memory>
#include "esphome/core/component.h"
#include "esphome/core/helpers.h"
namespace esphome {
class Component;
@@ -71,6 +73,7 @@ class Scheduler {
return this->items_.empty();
}
Mutex lock_;
std::vector<std::unique_ptr<SchedulerItem>> items_;
std::vector<std::unique_ptr<SchedulerItem>> to_add_;
uint32_t last_millis_{0};