Skip to content

Commit 1a1d6e6

Browse files
committed
[ORC] Add more synchronization to TestLookupWithUnthreadedMaterialization.
Don't run tasks until their corresponding thread has been added to the running threads vector. This is an extention to fda4300, which doesn't seem to have been enough to fix the synchronization issues on its own.
1 parent 2b45895 commit 1a1d6e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,14 @@ TEST_F(CoreAPIsStandardTest, TestLookupWithThreadedMaterialization) {
12521252
std::mutex WorkThreadsMutex;
12531253
std::vector<std::thread> WorkThreads;
12541254
ES.setDispatchTask([&](std::unique_ptr<Task> T) {
1255+
std::promise<void> WaitP;
12551256
std::lock_guard<std::mutex> Lock(WorkThreadsMutex);
12561257
WorkThreads.push_back(
1257-
std::thread([T = std::move(T)]() mutable { T->run(); }));
1258+
std::thread([T = std::move(T), WaitF = WaitP.get_future()]() mutable {
1259+
WaitF.get();
1260+
T->run();
1261+
}));
1262+
WaitP.set_value();
12581263
});
12591264

12601265
cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));

0 commit comments

Comments
 (0)