Don't run tasks until their corresponding thread has been added to the running
threads vector. This is an extention to
fda4300da82, which doesn't seem to have
been enough to fix the synchronization issues on its own.
std::mutex WorkThreadsMutex;
std::vector<std::thread> WorkThreads;
ES.setDispatchTask([&](std::unique_ptr<Task> T) {
+ std::promise<void> WaitP;
std::lock_guard<std::mutex> Lock(WorkThreadsMutex);
WorkThreads.push_back(
- std::thread([T = std::move(T)]() mutable { T->run(); }));
+ std::thread([T = std::move(T), WaitF = WaitP.get_future()]() mutable {
+ WaitF.get();
+ T->run();
+ }));
+ WaitP.set_value();
});
cantFail(JD.define(absoluteSymbols({{Foo, FooSym}})));