ccls/src/import_manager.h
Jacob Dufault 3599a831b1 Introduce MessageHandler abstraction. Mainly just code reorg.
Only the initialize request uses it so far, but this will enable pulling
quite a bit of code out of command_line.cc.
2017-12-04 23:57:41 -08:00

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_;
};