[clangd] Move threading helper to more appropriate header. NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@370864 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/CodeComplete.cpp b/clangd/CodeComplete.cpp
index 4340620..030b4ba 100644
--- a/clangd/CodeComplete.cpp
+++ b/clangd/CodeComplete.cpp
@@ -31,7 +31,7 @@
#include "Protocol.h"
#include "Quality.h"
#include "SourceCode.h"
-#include "TUScheduler.h"
+#include "Threading.h"
#include "Trace.h"
#include "URI.h"
#include "index/Index.h"
diff --git a/clangd/TUScheduler.h b/clangd/TUScheduler.h
index 3103af9..ff2d4d4 100644
--- a/clangd/TUScheduler.h
+++ b/clangd/TUScheduler.h
@@ -20,7 +20,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include <future>
namespace clang {
namespace clangd {
@@ -259,19 +258,6 @@
std::chrono::steady_clock::duration UpdateDebounce;
};
-/// Runs \p Action asynchronously with a new std::thread. The context will be
-/// propagated.
-template <typename T>
-std::future<T> runAsync(llvm::unique_function<T()> Action) {
- return std::async(
- std::launch::async,
- [](llvm::unique_function<T()> &&Action, Context Ctx) {
- WithContext WithCtx(std::move(Ctx));
- return Action();
- },
- std::move(Action), Context::current().clone());
-}
-
} // namespace clangd
} // namespace clang
diff --git a/clangd/Threading.h b/clangd/Threading.h
index 920b2e0..64caa49 100644
--- a/clangd/Threading.h
+++ b/clangd/Threading.h
@@ -14,6 +14,7 @@
#include "llvm/ADT/Twine.h"
#include <cassert>
#include <condition_variable>
+#include <future>
#include <memory>
#include <mutex>
#include <thread>
@@ -117,6 +118,19 @@
std::size_t InFlightTasks = 0;
};
+/// Runs \p Action asynchronously with a new std::thread. The context will be
+/// propagated.
+template <typename T>
+std::future<T> runAsync(llvm::unique_function<T()> Action) {
+ return std::async(
+ std::launch::async,
+ [](llvm::unique_function<T()> &&Action, Context Ctx) {
+ WithContext WithCtx(std::move(Ctx));
+ return Action();
+ },
+ std::move(Action), Context::current().clone());
+}
+
} // namespace clangd
} // namespace clang
#endif