summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdUnit.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2017-10-10 16:12:54 +0000
committerIlya Biryukov <ibiryukov@google.com>2017-10-10 16:12:54 +0000
commit98a1fd7f96cdabfff1c0b9b5448423f3cf2ac1d5 (patch)
tree4b1c53a2f397aef1c5f323b5d50cefad9d869a04 /clang-tools-extra/clangd/ClangdUnit.cpp
parenteab499d31b27ebe028896ac90b4ef56e6f7e5acd (diff)
downloadbcm5719-llvm-98a1fd7f96cdabfff1c0b9b5448423f3cf2ac1d5.tar.gz
bcm5719-llvm-98a1fd7f96cdabfff1c0b9b5448423f3cf2ac1d5.zip
[clangd] Use UniqueFunction for deferred computations.
Previsouly, `std::future` that were results of `std::async(std::launch::deferred, ...` were used. llvm-svn: 315325
Diffstat (limited to 'clang-tools-extra/clangd/ClangdUnit.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdUnit.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/clang-tools-extra/clangd/ClangdUnit.cpp b/clang-tools-extra/clangd/ClangdUnit.cpp
index ccf0283a294..a476eeb72e2 100644
--- a/clang-tools-extra/clangd/ClangdUnit.cpp
+++ b/clang-tools-extra/clangd/ClangdUnit.cpp
@@ -1121,9 +1121,9 @@ CppFile::CppFile(PathRef FileName, tooling::CompileCommand Command,
ASTFuture = ASTPromise.get_future();
}
-void CppFile::cancelRebuild() { deferCancelRebuild().get(); }
+void CppFile::cancelRebuild() { deferCancelRebuild()(); }
-std::future<void> CppFile::deferCancelRebuild() {
+UniqueFunction<void()> CppFile::deferCancelRebuild() {
std::unique_lock<std::mutex> Lock(Mutex);
// Cancel an ongoing rebuild, if any, and wait for it to finish.
unsigned RequestRebuildCounter = ++this->RebuildCounter;
@@ -1143,7 +1143,7 @@ std::future<void> CppFile::deferCancelRebuild() {
RebuildCond.notify_all();
std::shared_ptr<CppFile> That = shared_from_this();
- return std::async(std::launch::deferred, [That, RequestRebuildCounter]() {
+ return [That, RequestRebuildCounter]() {
std::unique_lock<std::mutex> Lock(That->Mutex);
CppFile *This = &*That;
This->RebuildCond.wait(Lock, [This, RequestRebuildCounter]() {
@@ -1158,16 +1158,16 @@ std::future<void> CppFile::deferCancelRebuild() {
// Set empty results for Promises.
That->PreamblePromise.set_value(nullptr);
That->ASTPromise.set_value(std::make_shared<ParsedASTWrapper>(llvm::None));
- });
+ };
}
llvm::Optional<std::vector<DiagWithFixIts>>
CppFile::rebuild(StringRef NewContents,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
- return deferRebuild(NewContents, std::move(VFS)).get();
+ return deferRebuild(NewContents, std::move(VFS))();
}
-std::future<llvm::Optional<std::vector<DiagWithFixIts>>>
+UniqueFunction<llvm::Optional<std::vector<DiagWithFixIts>>()>
CppFile::deferRebuild(StringRef NewContents,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
std::shared_ptr<const PreambleData> OldPreamble;
@@ -1315,7 +1315,7 @@ CppFile::deferRebuild(StringRef NewContents,
return Diagnostics;
};
- return std::async(std::launch::deferred, FinishRebuild, NewContents.str());
+ return BindWithForward(FinishRebuild, NewContents.str());
}
std::shared_future<std::shared_ptr<const PreambleData>>
OpenPOWER on IntegriCloud