1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Fix MSVC build with LLVM_ENABLE_THREADS=OFF

Follow-up to the ThreadPool implementation.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 255621
This commit is contained in:
Mehdi Amini 2015-12-15 05:53:41 +00:00
parent c058f3a850
commit 24492edbe4

View File

@ -125,16 +125,25 @@ void ThreadPool::wait() {
while (!Tasks.empty()) {
auto Task = std::move(Tasks.front());
Tasks.pop();
Task();
#ifndef _MSC_VER
Task();
#else
Task(/* unused */ false);
#endif
}
}
std::shared_future<ThreadPool::VoidTy> ThreadPool::asyncImpl(TaskTy Task) {
#ifndef _MSC_VER
// Get a Future with launch::deferred execution using std::async
auto Future = std::async(std::launch::deferred, std::move(Task)).share();
// Wrap the future so that both ThreadPool::wait() can operate and the
// returned future can be sync'ed on.
PackagedTaskTy PackagedTask([Future]() { Future.get(); });
#else
auto Future = std::async(std::launch::deferred, std::move(Task), false).share();
PackagedTaskTy PackagedTask([Future](bool) -> bool { Future.get(); return false; });
#endif
Tasks.push(std::move(PackagedTask));
return Future;
}