[llvm] r255621 - Fix MSVC build with LLVM_ENABLE_THREADS=OFF

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 21:53:42 PST 2015


Author: mehdi_amini
Date: Mon Dec 14 23:53:41 2015
New Revision: 255621

URL: http://llvm.org/viewvc/llvm-project?rev=255621&view=rev
Log:
Fix MSVC build with LLVM_ENABLE_THREADS=OFF

Follow-up to the ThreadPool implementation.

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/lib/Support/ThreadPool.cpp

Modified: llvm/trunk/lib/Support/ThreadPool.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ThreadPool.cpp?rev=255621&r1=255620&r2=255621&view=diff
==============================================================================
--- llvm/trunk/lib/Support/ThreadPool.cpp (original)
+++ llvm/trunk/lib/Support/ThreadPool.cpp Mon Dec 14 23:53:41 2015
@@ -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;
 }




More information about the llvm-commits mailing list