mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 17:41:58 +00:00
3599a831b1
Only the initialize request uses it so far, but this will enable pulling quite a bit of code out of command_line.cc.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <unordered_set>
|
|
|
|
// Manages files inside of the indexing pipeline so we don't have the same file
|
|
// being imported multiple times.
|
|
//
|
|
// NOTE: This is not thread safe and should only be used on the querydb thread.
|
|
struct ImportManager {
|
|
// Try to mark the given dependency as imported. A dependency can only ever be
|
|
// imported once.
|
|
bool TryMarkDependencyImported(const std::string& path);
|
|
|
|
// Try to import the given file into querydb. We should only ever be
|
|
// importing a file into querydb once per file. Returns true if the file
|
|
// can be imported.
|
|
bool StartQueryDbImport(const std::string& path);
|
|
|
|
// The file has been fully imported and can be imported again later on.
|
|
void DoneQueryDbImport(const std::string& path);
|
|
|
|
// Returns true if there any any files currently being imported.
|
|
bool HasActiveQuerydbImports();
|
|
|
|
std::unordered_set<std::string> querydb_processing_;
|
|
|
|
// TODO: use std::shared_mutex so we can have multiple readers.
|
|
std::mutex depdency_mutex_;
|
|
std::unordered_set<std::string> depdency_imported_;
|
|
}; |