#pragma once #include "ipc.h" #include "performance.h" #include "query.h" #include "threaded_queue.h" #include struct lsBaseOutMessage; struct Stdout_Request { IpcId id; std::string content; }; struct Index_Request { std::string path; // TODO: make |args| a string that is parsed lazily. std::vector args; bool is_interactive; std::string contents; // Preloaded contents. Useful for tests. Index_Request(const std::string& path, const std::vector& args, bool is_interactive, const std::string& contents); }; struct Index_DoIdMap { std::unique_ptr current; std::unique_ptr previous; PerformanceImportFile perf; bool is_interactive = false; bool write_to_disk = false; bool load_previous = false; Index_DoIdMap(std::unique_ptr current, PerformanceImportFile perf, bool is_interactive, bool write_to_disk); }; struct Index_OnIdMapped { struct File { std::unique_ptr file; std::unique_ptr ids; File(std::unique_ptr file, std::unique_ptr ids); }; std::unique_ptr previous; std::unique_ptr current; PerformanceImportFile perf; bool is_interactive; bool write_to_disk; Index_OnIdMapped(PerformanceImportFile perf, bool is_interactive, bool write_to_disk); }; struct Index_OnIndexed { IndexUpdate update; PerformanceImportFile perf; Index_OnIndexed(IndexUpdate& update, PerformanceImportFile perf); }; struct QueueManager { static QueueManager* instance(); static void CreateInstance(MultiQueueWaiter* waiter); static void WriteStdout(IpcId id, lsBaseOutMessage& response); bool HasWork(); // Runs on stdout thread. ThreadedQueue for_stdout; // Runs on querydb thread. ThreadedQueue> for_querydb; // Runs on indexer threads. ThreadedQueue index_request; ThreadedQueue do_id_map; ThreadedQueue load_previous_index; ThreadedQueue on_id_mapped; ThreadedQueue on_indexed; private: explicit QueueManager(MultiQueueWaiter* waiter); static QueueManager* instance_; };