sammccall updated this revision to Diff 164012.
sammccall added a comment.
Don't load index asynchronously if -run-synchronously is passed.
Nothing needs this today, but it's less surprising behavior.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D51674
Files:
clangd/tool/ClangdMain.cpp
Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -271,14 +271,17 @@
Opts.ResourceDir = ResourceDir;
Opts.BuildDynamicSymbolIndex = EnableIndex;
std::unique_ptr<SymbolIndex> StaticIdx;
+ std::future<void> AsyncIndexLoad; // Block exit while loading the index.
if (EnableIndex && !YamlSymbolFile.empty()) {
// Load the index asynchronously. Meanwhile SwapIndex returns no results.
SwapIndex *Placeholder;
StaticIdx.reset(Placeholder = new
SwapIndex(llvm::make_unique<MemIndex>()));
- runAsync<void>([Placeholder] {
+ AsyncIndexLoad = runAsync<void>([Placeholder] {
if (auto Idx = loadIndex(YamlSymbolFile))
Placeholder->reset(std::move(Idx));
});
+ if (RunSynchronously)
+ AsyncIndexLoad.wait();
}
Opts.StaticIndex = StaticIdx.get();
Opts.AsyncThreadsCount = WorkerThreadsCount;
Index: clangd/tool/ClangdMain.cpp
===================================================================
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -271,14 +271,17 @@
Opts.ResourceDir = ResourceDir;
Opts.BuildDynamicSymbolIndex = EnableIndex;
std::unique_ptr<SymbolIndex> StaticIdx;
+ std::future<void> AsyncIndexLoad; // Block exit while loading the index.
if (EnableIndex && !YamlSymbolFile.empty()) {
// Load the index asynchronously. Meanwhile SwapIndex returns no results.
SwapIndex *Placeholder;
StaticIdx.reset(Placeholder = new SwapIndex(llvm::make_unique<MemIndex>()));
- runAsync<void>([Placeholder] {
+ AsyncIndexLoad = runAsync<void>([Placeholder] {
if (auto Idx = loadIndex(YamlSymbolFile))
Placeholder->reset(std::move(Idx));
});
+ if (RunSynchronously)
+ AsyncIndexLoad.wait();
}
Opts.StaticIndex = StaticIdx.get();
Opts.AsyncThreadsCount = WorkerThreadsCount;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits