[clangd] Propogate context in TUScheduler::run
Reviewers: sammccall Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69328
This commit is contained in:
parent
977205b595
commit
10c8dbcb84
|
@ -44,6 +44,7 @@
|
||||||
#include "TUScheduler.h"
|
#include "TUScheduler.h"
|
||||||
#include "Cancellation.h"
|
#include "Cancellation.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
#include "Context.h"
|
||||||
#include "Diagnostics.h"
|
#include "Diagnostics.h"
|
||||||
#include "GlobalCompilationDatabase.h"
|
#include "GlobalCompilationDatabase.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
@ -919,7 +920,11 @@ void TUScheduler::run(llvm::StringRef Name,
|
||||||
llvm::unique_function<void()> Action) {
|
llvm::unique_function<void()> Action) {
|
||||||
if (!PreambleTasks)
|
if (!PreambleTasks)
|
||||||
return Action();
|
return Action();
|
||||||
PreambleTasks->runAsync(Name, std::move(Action));
|
PreambleTasks->runAsync(Name, [Ctx = Context::current().clone(),
|
||||||
|
Action = std::move(Action)]() mutable {
|
||||||
|
WithContext WC(std::move(Ctx));
|
||||||
|
Action();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TUScheduler::runWithAST(
|
void TUScheduler::runWithAST(
|
||||||
|
|
|
@ -688,6 +688,15 @@ TEST_F(TUSchedulerTests, Run) {
|
||||||
S.run("add 2", [&] { Counter += 2; });
|
S.run("add 2", [&] { Counter += 2; });
|
||||||
ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
|
ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
|
||||||
EXPECT_EQ(Counter.load(), 3);
|
EXPECT_EQ(Counter.load(), 3);
|
||||||
|
|
||||||
|
Notification TaskRun;
|
||||||
|
Key<int> TestKey;
|
||||||
|
WithContextValue CtxWithKey(TestKey, 10);
|
||||||
|
S.run("props context", [&] {
|
||||||
|
EXPECT_EQ(Context::current().getExisting(TestKey), 10);
|
||||||
|
TaskRun.notify();
|
||||||
|
});
|
||||||
|
TaskRun.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TUSchedulerTests, TUStatus) {
|
TEST_F(TUSchedulerTests, TUStatus) {
|
||||||
|
|
Loading…
Reference in New Issue