[clang-tools-extra] r341538 - [clangd] Fix data race in async fuzzyFind tests.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 6 04:04:56 PDT 2018
Author: ibiryukov
Date: Thu Sep 6 04:04:56 2018
New Revision: 341538
URL: http://llvm.org/viewvc/llvm-project?rev=341538&view=rev
Log:
[clangd] Fix data race in async fuzzyFind tests.
Modified:
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=341538&r1=341537&r2=341538&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Sep 6 04:04:56 2018
@@ -966,6 +966,7 @@ public:
bool
fuzzyFind(const FuzzyFindRequest &Req,
llvm::function_ref<void(const Symbol &)> Callback) const override {
+ std::lock_guard<std::mutex> Lock(Mut);
Requests.push_back(Req);
return true;
}
@@ -981,12 +982,15 @@ public:
size_t estimateMemoryUsage() const override { return 0; }
const std::vector<FuzzyFindRequest> consumeRequests() const {
+ std::lock_guard<std::mutex> Lock(Mut);
auto Reqs = std::move(Requests);
Requests = {};
return Reqs;
}
private:
+ // We need a mutex to handle async fuzzy find requests.
+ mutable std::mutex Mut;
mutable std::vector<FuzzyFindRequest> Requests;
};
More information about the cfe-commits
mailing list