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)>;
75 size_t BuildIndexPeriodMs = 0,
76 size_t ThreadPoolSize = llvm::heavyweight_hardware_concurrency());
82 void enqueue(
const std::vector<std::string> &ChangedFiles);
90 blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
97 const llvm::StringMap<FileDigest> &DigestsSnapshot,
106 llvm::Error index(tooling::CompileCommand,
109 const size_t BuildIndexPeriodMs;
110 std::atomic<bool> SymbolsUpdatedSinceLastIndex;
112 std::condition_variable IndexCV;
115 llvm::StringMap<FileDigest> IndexedFileDigests;
116 std::mutex DigestsMu;
121 bool NeedsReIndexing;
122 Source(llvm::StringRef Path,
bool NeedsReIndexing)
123 :
Path(Path), NeedsReIndexing(NeedsReIndexing) {}
127 std::vector<Source>
loadShard(
const tooling::CompileCommand &Cmd,
129 llvm::StringSet<> &LoadedShards);
131 std::vector<std::pair<tooling::CompileCommand, BackgroundIndexStorage *>>
132 loadShards(std::vector<std::string> ChangedFiles);
136 using Task = std::function<void()>;
139 void enqueueLocked(tooling::CompileCommand Cmd,
142 unsigned NumActiveTasks = 0;
143 std::condition_variable QueueCV;
144 bool ShouldStop =
false;
145 std::deque<std::pair<Task, ThreadPriority>> Queue;
146 std::vector<std::thread> ThreadPool;
147 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