新的opus封装以及优化const会导致的内存拷贝

This commit is contained in:
Terrence
2024-12-04 02:12:20 +08:00
parent 9c1f8a1d06
commit bcfd120b00
15 changed files with 102 additions and 102 deletions

View File

@@ -31,12 +31,16 @@ void BackgroundTask::Schedule(std::function<void()> callback) {
ESP_LOGW(TAG, "active_tasks_ == %u", active_tasks_.load());
}
active_tasks_++;
auto wrapped_callback = [this, callback]() {
callback();
active_tasks_--;
condition_variable_.notify_all();
};
main_tasks_.push_back(wrapped_callback);
main_tasks_.emplace_back([this, cb = std::move(callback)]() {
cb();
{
std::lock_guard<std::mutex> lock(mutex_);
active_tasks_--;
if (main_tasks_.empty() && active_tasks_ == 0) {
condition_variable_.notify_all();
}
}
});
condition_variable_.notify_all();
}