10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H 20 #include "clang/Tooling/CompilationDatabase.h" 21 #include "llvm/ADT/StringMap.h" 22 #include "llvm/Support/SHA1.h" 23 #include "llvm/Support/Threading.h" 25 #include <condition_variable> 43 virtual llvm::Error
storeShard(llvm::StringRef ShardIdentifier,
48 virtual std::unique_ptr<IndexFileIn>
49 loadShard(llvm::StringRef ShardIdentifier)
const = 0;
55 llvm::unique_function<BackgroundIndexStorage *(llvm::StringRef)>;
74 size_t BuildIndexPeriodMs = 0,
75 size_t ThreadPoolSize = llvm::hardware_concurrency());
81 void enqueue(
const std::vector<std::string> &ChangedFiles);
89 blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
96 const llvm::StringMap<FileDigest> &DigestsSnapshot,
105 llvm::Error index(tooling::CompileCommand,
108 const size_t BuildIndexPeriodMs;
109 std::atomic<bool> SymbolsUpdatedSinceLastIndex;
111 std::condition_variable IndexCV;
114 llvm::StringMap<FileDigest> IndexedFileDigests;
115 std::mutex DigestsMu;
120 bool NeedsReIndexing;
121 Source(llvm::StringRef Path,
bool NeedsReIndexing)
122 :
Path(Path), NeedsReIndexing(NeedsReIndexing) {}
126 std::vector<Source>
loadShard(
const tooling::CompileCommand &Cmd,
128 llvm::StringSet<> &LoadedShards);
130 std::vector<std::pair<tooling::CompileCommand, BackgroundIndexStorage *>>
131 loadShards(std::vector<std::string> ChangedFiles);
135 using Task = std::function<void()>;
138 void enqueueLocked(tooling::CompileCommand Cmd,
141 unsigned NumActiveTasks = 0;
142 std::condition_variable QueueCV;
143 bool ShouldStop =
false;
144 std::deque<std::pair<Task, ThreadPriority>> Queue;
145 std::vector<std::thread> ThreadPool;
146 GlobalCompilationDatabase::CommandChanged::Subscription CommandsChanged;
A container of Symbols from several source files.
static Factory createDiskBackedStorageFactory()
llvm::unique_function< BackgroundIndexStorage *(llvm::StringRef)> Factory
Provides compilation arguments used for parsing C and C++ files.
std::string Path
A typedef to represent a file path.
A context is an immutable container for per-request data that must be propagated through layers that ...
virtual std::unique_ptr< IndexFileIn > loadShard(llvm::StringRef ShardIdentifier) const =0
virtual llvm::Error storeShard(llvm::StringRef ShardIdentifier, IndexFileOut Shard) const =0
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
virtual ~BackgroundIndexStorage()=default
const SymbolIndex * Index