Move prepared-file work into app runtime

This commit is contained in:
2026-06-16 08:24:19 +02:00
parent 640ebc4be4
commit 3e4eb89499
9 changed files with 162 additions and 110 deletions

View File

@@ -34,6 +34,9 @@ struct AppTask : public std::packaged_task<void()>
class AppRuntime
{
public:
AppRuntime();
~AppRuntime();
[[nodiscard]] bool is_render_thread() const noexcept;
[[nodiscard]] bool is_ui_thread() const noexcept;
[[nodiscard]] bool request_redraw() const noexcept { return request_redraw_; }
@@ -41,6 +44,7 @@ public:
void notify_render_worker() noexcept;
void notify_ui_worker() noexcept;
void prepared_file_task(std::function<void()> task);
void render_thread_tick(App& app);
void render_thread_main(App& app, std::stop_token stop_token);
@@ -199,6 +203,15 @@ public:
}
private:
void prepared_file_worker_main(std::stop_token stop_token);
void prepared_file_worker_stop();
std::deque<std::function<void()>> prepared_file_tasklist_;
std::mutex prepared_file_task_mutex_;
std::condition_variable prepared_file_cv_;
std::jthread prepared_file_worker_;
bool prepared_file_running_ = true;
std::deque<AppTask> render_tasklist_;
std::mutex render_task_mutex_;
std::condition_variable render_cv_;