Trim recording loop and retain async worker state

This commit is contained in:
2026-06-16 08:16:59 +02:00
parent 76ca2eea1a
commit 640ebc4be4
6 changed files with 87 additions and 37 deletions

View File

@@ -89,10 +89,19 @@ private:
std::jthread worker_;
};
LegacyPreparedFileWorker& prepared_file_worker()
struct RetainedPreparedFileWorkerState final {
void post(std::function<void()> task)
{
worker.post(std::move(task));
}
LegacyPreparedFileWorker worker;
};
RetainedPreparedFileWorkerState& retained_prepared_file_worker_state()
{
static LegacyPreparedFileWorker worker;
return worker;
static RetainedPreparedFileWorkerState state;
return state;
}
[[nodiscard]] GLint rgba8_internal_format() noexcept
@@ -284,7 +293,7 @@ void App::pick_file_save(const std::string& type, const std::string& default_nam
LOG("App::pick_file_save %s", target.path.c_str());
if (target.write_on_background_thread) {
auto* app = this;
prepared_file_worker().post([
retained_prepared_file_worker_state().post([
app,
writer = std::move(writer),
callback = std::move(callback),