#if false #pragma once #include #include #include #include #include #include enum class TaskThread { Indexer, QueryDb, }; struct TaskManager { using TTask = std::function; using TIdleTask = std::function; TaskManager(); // Run |task| at some point in the future. This will run the task as soon as possible. void Post(TaskThread thread, const TTask& task); // Run |task| whenever there is nothing else to run. void SetIdle(TaskThread thread, const TIdleTask& idle_task); // Run pending tasks for |thread|. Stop running tasks after |max_time| has // elapsed. Returns true if tasks were run. bool RunTasks(TaskThread thread, optional> max_time); struct TaskQueue { optional idle_task; std::vector tasks; std::mutex tasks_mutex; }; std::unordered_map> pending_tasks_; }; #endif