Skip to content

Commit 4ca7185

Browse files
committed
[clangd] Move threading helper to more appropriate header. NFC
llvm-svn: 370864
1 parent 5aa1d81 commit 4ca7185

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "Protocol.h"
3232
#include "Quality.h"
3333
#include "SourceCode.h"
34-
#include "TUScheduler.h"
34+
#include "Threading.h"
3535
#include "Trace.h"
3636
#include "URI.h"
3737
#include "index/Index.h"

clang-tools-extra/clangd/TUScheduler.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "llvm/ADT/STLExtras.h"
2121
#include "llvm/ADT/StringMap.h"
2222
#include "llvm/ADT/StringRef.h"
23-
#include <future>
2423

2524
namespace clang {
2625
namespace clangd {
@@ -259,19 +258,6 @@ class TUScheduler {
259258
std::chrono::steady_clock::duration UpdateDebounce;
260259
};
261260

262-
/// Runs \p Action asynchronously with a new std::thread. The context will be
263-
/// propagated.
264-
template <typename T>
265-
std::future<T> runAsync(llvm::unique_function<T()> Action) {
266-
return std::async(
267-
std::launch::async,
268-
[](llvm::unique_function<T()> &&Action, Context Ctx) {
269-
WithContext WithCtx(std::move(Ctx));
270-
return Action();
271-
},
272-
std::move(Action), Context::current().clone());
273-
}
274-
275261
} // namespace clangd
276262
} // namespace clang
277263

clang-tools-extra/clangd/Threading.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/ADT/Twine.h"
1515
#include <cassert>
1616
#include <condition_variable>
17+
#include <future>
1718
#include <memory>
1819
#include <mutex>
1920
#include <thread>
@@ -117,6 +118,19 @@ class AsyncTaskRunner {
117118
std::size_t InFlightTasks = 0;
118119
};
119120

121+
/// Runs \p Action asynchronously with a new std::thread. The context will be
122+
/// propagated.
123+
template <typename T>
124+
std::future<T> runAsync(llvm::unique_function<T()> Action) {
125+
return std::async(
126+
std::launch::async,
127+
[](llvm::unique_function<T()> &&Action, Context Ctx) {
128+
WithContext WithCtx(std::move(Ctx));
129+
return Action();
130+
},
131+
std::move(Action), Context::current().clone());
132+
}
133+
120134
} // namespace clangd
121135
} // namespace clang
122136
#endif

0 commit comments

Comments
 (0)