Made some opimizations

This commit is contained in:
CommanderRedYT
2022-10-13 16:48:32 +02:00
parent 1840030461
commit f2350c8746
4 changed files with 23 additions and 6 deletions

View File

@@ -115,7 +115,7 @@ void sched_pushStats(bool printTasks)
ESP_LOGI(TAG, "end listing tasks");
}
tl::expected<bool, std::string> checkInitializedByName(std::string name)
tl::expected<bool, std::string> checkInitializedByName(const std::string& name)
{
for (auto &schedulerTask : schedulerTasks)
{
@@ -126,7 +126,7 @@ tl::expected<bool, std::string> checkInitializedByName(std::string name)
return tl::make_unexpected("Task not found: " + std::string{name});
}
bool checkEnabledByName(std::string name) {
bool checkEnabledByName(const std::string& name) {
bool enabled = true;
// iterate over all feature flags (runForEveryFeature())
configs.callForEveryFeature([&](ConfiguredFeatureFlag &feature) {
@@ -135,3 +135,14 @@ bool checkEnabledByName(std::string name) {
});
return enabled;
}
void reload_tasks()
{
for (auto &task : schedulerTasks)
{
if (checkEnabledByName(task.name()) && !task.isInitialized())
{
task.setup();
}
}
}