forked from MaskRay/ccls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue_manager.h
84 lines (67 loc) · 2.28 KB
/
queue_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include "method.h"
#include "query.h"
#include "threaded_queue.h"
#include <memory>
struct ICacheManager;
struct lsBaseOutMessage;
struct Stdout_Request {
MethodType method;
std::string content;
};
struct Index_Request {
std::string path;
// TODO: make |args| a string that is parsed lazily.
std::vector<std::string> args;
bool is_interactive;
lsRequestId id;
Index_Request(const std::string& path,
const std::vector<std::string>& args,
bool is_interactive,
lsRequestId id = {});
};
struct Index_OnIdMapped {
std::shared_ptr<ICacheManager> cache_manager;
std::unique_ptr<IndexFile> previous;
std::unique_ptr<IndexFile> current;
PerformanceImportFile perf;
bool is_interactive;
bool write_to_disk;
Index_OnIdMapped(const std::shared_ptr<ICacheManager>& cache_manager,
std::unique_ptr<IndexFile> previous,
std::unique_ptr<IndexFile> current,
PerformanceImportFile perf,
bool is_interactive,
bool write_to_disk)
: cache_manager(cache_manager),
previous(std::move(previous)),
current(std::move(current)),
perf(perf),
is_interactive(is_interactive),
write_to_disk(write_to_disk) {}
};
struct Index_OnIndexed {
IndexUpdate update;
PerformanceImportFile perf;
Index_OnIndexed(IndexUpdate&& update, PerformanceImportFile perf);
};
class QueueManager {
static std::unique_ptr<QueueManager> instance_;
public:
static QueueManager* instance() { return instance_.get(); }
static void Init(MultiQueueWaiter* querydb_waiter,
MultiQueueWaiter* indexer_waiter,
MultiQueueWaiter* stdout_waiter);
static void WriteStdout(MethodType method, lsBaseOutMessage& response);
// Messages received by "stdout" thread.
ThreadedQueue<Stdout_Request> for_stdout;
// Runs on querydb thread.
ThreadedQueue<std::unique_ptr<InMessage>> for_querydb;
ThreadedQueue<Index_OnIndexed> on_indexed;
// Runs on indexer threads.
ThreadedQueue<Index_Request> index_request;
private:
explicit QueueManager(MultiQueueWaiter* querydb_waiter,
MultiQueueWaiter* indexer_waiter,
MultiQueueWaiter* stdout_waiter);
};