fix CPU usage of esp32c3 with ml307

This commit is contained in:
Terrence
2025-06-29 05:40:27 +08:00
parent f2f54ba1fd
commit d1c586239c
4 changed files with 34 additions and 17 deletions

View File

@ -13,7 +13,7 @@ public:
BackgroundTask(uint32_t stack_size = 4096 * 2);
~BackgroundTask();
void Schedule(std::function<void()> callback);
bool Schedule(std::function<void()> callback);
void WaitForCompletion();
private:
@ -21,7 +21,8 @@ private:
std::list<std::function<void()>> background_tasks_;
std::condition_variable condition_variable_;
TaskHandle_t background_task_handle_ = nullptr;
std::atomic<size_t> active_tasks_{0};
int active_tasks_ = 0;
int waiting_for_completion_ = 0;
void BackgroundTaskLoop();
};