llvm.org GIT mirror llvm / d99f1b2
Fix MSVC build with LLVM_ENABLE_THREADS=OFF Follow-up to the ThreadPool implementation. From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255621 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
1 changed file(s) with 10 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
124124 while (!Tasks.empty()) {
125125 auto Task = std::move(Tasks.front());
126126 Tasks.pop();
127 Task();
127 #ifndef _MSC_VER
128 Task();
129 #else
130 Task(/* unused */ false);
131 #endif
128132 }
129133 }
130134
131135 std::shared_future ThreadPool::asyncImpl(TaskTy Task) {
136 #ifndef _MSC_VER
132137 // Get a Future with launch::deferred execution using std::async
133138 auto Future = std::async(std::launch::deferred, std::move(Task)).share();
134139 // Wrap the future so that both ThreadPool::wait() can operate and the
135140 // returned future can be sync'ed on.
136141 PackagedTaskTy PackagedTask([Future]() { Future.get(); });
142 #else
143 auto Future = std::async(std::launch::deferred, std::move(Task), false).share();
144 PackagedTaskTy PackagedTask([Future](bool) -> bool { Future.get(); return false; });
145 #endif
137146 Tasks.push(std::move(PackagedTask));
138147 return Future;
139148 }