Fix MSVC build with LLVM_ENABLE_THREADS=OFF
authorMehdi Amini <mehdi.amini@apple.com>
Tue, 15 Dec 2015 05:53:41 +0000 (05:53 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Tue, 15 Dec 2015 05:53:41 +0000 (05:53 +0000)
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

lib/Support/ThreadPool.cpp

index bc004dfb8a87b5792254f0737cc5b7e447333714..d4dcb2ee96df851e5542c80cef0d974b98325420 100644 (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;
 }