]> granicus.if.org Git - llvm/commitdiff
[Orc] Roll back ThreadPool to std::function
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 13 Sep 2019 11:59:51 +0000 (11:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 13 Sep 2019 11:59:51 +0000 (11:59 +0000)
MSVC doesn't allow move-only types in std::packaged_task. Boo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371844 91177308-0d34-0410-b5e6-96231b3b80d8

examples/SpeculativeJIT/SpeculativeJIT.cpp
include/llvm/Support/ThreadPool.h
lib/ExecutionEngine/Orc/LLJIT.cpp

index 647413cc9c2ae89ece957b5f464925b8ff3fa5b6..1fd1fc92a73f9225898272e0db9f74878a8704a8 100644 (file)
@@ -114,7 +114,9 @@ private:
     this->ES->setDispatchMaterialization(
 
         [this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
-          auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); };
+          // FIXME: Switch to move capture once we have C++14.
+          auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
+          auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
           CompileThreads.async(std::move(Work));
         });
     ExitOnErr(S.addSpeculationRuntime(this->ES->getMainJITDylib(), Mangle));
index 32f88124ee555dff43eb1293236fbb050d3b1ec7..4bcbaa3142fd4f1c2d9b17d827a3bf9b7163ade8 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef LLVM_SUPPORT_THREAD_POOL_H
 #define LLVM_SUPPORT_THREAD_POOL_H
 
-#include "llvm/ADT/FunctionExtras.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/thread.h"
 
@@ -36,7 +35,7 @@ namespace llvm {
 /// for some work to become available.
 class ThreadPool {
 public:
-  using TaskTy = unique_function<void()>;
+  using TaskTy = std::function<void()>;
   using PackagedTaskTy = std::packaged_task<void()>;
 
   /// Construct a pool with the number of threads found by
index c6532c60fb8e313595389f3be34064b3ffa1e574..a80f78afe80f9c6d91c4a8d54747f0427a108a62 100644 (file)
@@ -132,7 +132,9 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
     CompileThreads = std::make_unique<ThreadPool>(S.NumCompileThreads);
     ES->setDispatchMaterialization(
         [this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
-          auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); };
+          // FIXME: Switch to move capture once we have c++14.
+          auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
+          auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
           CompileThreads->async(std::move(Work));
         });
   }