diff options
-rw-r--r-- | clang-tools-extra/clangd/index/Background.cpp | 7 | ||||
-rw-r--r-- | clang-tools-extra/clangd/index/Background.h | 2 | ||||
-rw-r--r-- | clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp | 3 |
3 files changed, 6 insertions, 6 deletions
diff --git a/clang-tools-extra/clangd/index/Background.cpp b/clang-tools-extra/clangd/index/Background.cpp index dac8bb9f909..f6de39549f4 100644 --- a/clang-tools-extra/clangd/index/Background.cpp +++ b/clang-tools-extra/clangd/index/Background.cpp @@ -75,8 +75,11 @@ void BackgroundIndex::blockUntilIdleForTest() { void BackgroundIndex::enqueue(StringRef Directory, tooling::CompileCommand Cmd) { - std::lock_guard<std::mutex> Lock(QueueMu); - enqueueLocked(std::move(Cmd)); + { + std::lock_guard<std::mutex> Lock(QueueMu); + enqueueLocked(std::move(Cmd)); + } + QueueCV.notify_all(); } void BackgroundIndex::enqueueAll(StringRef Directory, diff --git a/clang-tools-extra/clangd/index/Background.h b/clang-tools-extra/clangd/index/Background.h index 535e12d30b2..3f52423faa8 100644 --- a/clang-tools-extra/clangd/index/Background.h +++ b/clang-tools-extra/clangd/index/Background.h @@ -65,12 +65,12 @@ private: using Task = std::function<void()>; // FIXME: use multiple worker threads. void run(); // Main loop executed by Thread. Runs tasks from Queue. void enqueueLocked(tooling::CompileCommand Cmd); - std::thread Thread; std::mutex QueueMu; unsigned NumActiveTasks = 0; // Only idle when queue is empty *and* no tasks. std::condition_variable QueueCV; bool ShouldStop = false; std::deque<Task> Queue; + std::thread Thread; // Must be last, spawned thread reads instance vars. }; } // namespace clangd diff --git a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp index 1ea75fa5c08..93bf62bba1d 100644 --- a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp +++ b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp @@ -11,8 +11,6 @@ namespace clangd { MATCHER_P(Named, N, "") { return arg.Name == N; } -// Temporarily disabled: test timing out on buildbots. -#if 0 TEST(BackgroundIndexTest, IndexTwoFiles) { MockFSProvider FS; // a.h yields different symbols when included by A.cc vs B.cc. @@ -34,7 +32,6 @@ TEST(BackgroundIndexTest, IndexTwoFiles) { EXPECT_THAT(runFuzzyFind(Idx, ""), UnorderedElementsAre(Named("a_h"), Named("foo"), Named("bar"))); } -#endif } // namespace clangd } // namespace clang |