mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 07:08:20 +00:00
Lint
This commit is contained in:
parent
44f9874645
commit
18324f2a5b
@ -7,7 +7,8 @@ namespace esphome {
|
|||||||
|
|
||||||
static const char *TAG = "scheduler";
|
static const char *TAG = "scheduler";
|
||||||
|
|
||||||
void HOT Scheduler::set_timeout(Component *component, const std::string &name, uint32_t timeout, std::function<void()> &&func) {
|
void HOT Scheduler::set_timeout(Component *component, const std::string &name, uint32_t timeout,
|
||||||
|
std::function<void()> &&func) {
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
|
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
@ -28,10 +29,8 @@ void HOT Scheduler::set_timeout(Component *component, const std::string &name, u
|
|||||||
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, name, SchedulerItem::TIMEOUT);
|
||||||
}
|
}
|
||||||
void HOT Scheduler::set_interval(Component *component,
|
void HOT Scheduler::set_interval(Component *component, const std::string &name, uint32_t interval,
|
||||||
const std::string &name,
|
std::function<void()> &&func) {
|
||||||
uint32_t interval,
|
|
||||||
std::function<void()> &&func) {
|
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
|
|
||||||
// only put offset in lower half
|
// only put offset in lower half
|
||||||
@ -89,8 +88,7 @@ void ICACHE_RAM_ATTR HOT Scheduler::call() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||||
const char *type =
|
const char *type = item.type == SchedulerItem::INTERVAL ? "interval" : "timeout";
|
||||||
item.type == SchedulerItem::INTERVAL ? "interval" : "timeout";
|
|
||||||
ESP_LOGVV(TAG, "Running %s '%s' with interval=%u last_execution=%u (now=%u)", type, item.name.c_str(),
|
ESP_LOGVV(TAG, "Running %s '%s' with interval=%u last_execution=%u (now=%u)", type, item.name.c_str(),
|
||||||
item.interval, item.last_execution, now);
|
item.interval, item.last_execution, now);
|
||||||
#endif
|
#endif
|
||||||
@ -127,24 +125,18 @@ void HOT Scheduler::cleanup_() {
|
|||||||
}
|
}
|
||||||
bool HOT Scheduler::peek_() {
|
bool HOT Scheduler::peek_() {
|
||||||
this->cleanup_();
|
this->cleanup_();
|
||||||
if (this->items_.empty())
|
return !this->items_.empty();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
bool HOT Scheduler::pop_() {
|
bool HOT Scheduler::pop_() {
|
||||||
this->cleanup_();
|
this->cleanup_();
|
||||||
if (this->items_.empty())
|
return !this->items_.empty();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
void HOT Scheduler::pop_raw_() {
|
void HOT Scheduler::pop_raw_() {
|
||||||
std::pop_heap(this->items_.begin(), this->items_.end());
|
std::pop_heap(this->items_.begin(), this->items_.end());
|
||||||
auto item = this->items_.back();
|
auto item = this->items_.back();
|
||||||
this->items_.pop_back();
|
this->items_.pop_back();
|
||||||
}
|
}
|
||||||
void HOT Scheduler::push_(const Scheduler::SchedulerItem &item) {
|
void HOT Scheduler::push_(const Scheduler::SchedulerItem &item) { this->to_add_.push_back(item); }
|
||||||
this->to_add_.push_back(item);
|
|
||||||
}
|
|
||||||
bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, Scheduler::SchedulerItem::Type type) {
|
bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, Scheduler::SchedulerItem::Type type) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (auto &it : this->items_)
|
for (auto &it : this->items_)
|
||||||
|
@ -39,7 +39,7 @@ class Scheduler {
|
|||||||
bool peek_();
|
bool peek_();
|
||||||
bool pop_();
|
bool pop_();
|
||||||
void pop_raw_();
|
void pop_raw_();
|
||||||
void push_(const SchedulerItem& item);
|
void push_(const SchedulerItem &item);
|
||||||
bool cancel_item_(Component *component, const std::string &name, SchedulerItem::Type type);
|
bool cancel_item_(Component *component, const std::string &name, SchedulerItem::Type type);
|
||||||
|
|
||||||
std::vector<SchedulerItem> items_;
|
std::vector<SchedulerItem> items_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user