Skip to content

Commit 6baaa4b

Browse files
committed
[Orc] Roll back ThreadPool to std::function
MSVC doesn't allow move-only types in std::packaged_task. Boo. llvm-svn: 371844
1 parent ce74c3b commit 6baaa4b

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ class SpeculativeJIT {
114114
this->ES->setDispatchMaterialization(
115115

116116
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
117-
auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); };
117+
// FIXME: Switch to move capture once we have C++14.
118+
auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
119+
auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
118120
CompileThreads.async(std::move(Work));
119121
});
120122
ExitOnErr(S.addSpeculationRuntime(this->ES->getMainJITDylib(), Mangle));

llvm/include/llvm/Support/ThreadPool.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef LLVM_SUPPORT_THREAD_POOL_H
1414
#define LLVM_SUPPORT_THREAD_POOL_H
1515

16-
#include "llvm/ADT/FunctionExtras.h"
1716
#include "llvm/Config/llvm-config.h"
1817
#include "llvm/Support/thread.h"
1918

@@ -36,7 +35,7 @@ namespace llvm {
3635
/// for some work to become available.
3736
class ThreadPool {
3837
public:
39-
using TaskTy = unique_function<void()>;
38+
using TaskTy = std::function<void()>;
4039
using PackagedTaskTy = std::packaged_task<void()>;
4140

4241
/// Construct a pool with the number of threads found by

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
132132
CompileThreads = std::make_unique<ThreadPool>(S.NumCompileThreads);
133133
ES->setDispatchMaterialization(
134134
[this](JITDylib &JD, std::unique_ptr<MaterializationUnit> MU) {
135-
auto Work = [MU = std::move(MU), &JD] { MU->doMaterialize(JD); };
135+
// FIXME: Switch to move capture once we have c++14.
136+
auto SharedMU = std::shared_ptr<MaterializationUnit>(std::move(MU));
137+
auto Work = [SharedMU, &JD]() { SharedMU->doMaterialize(JD); };
136138
CompileThreads->async(std::move(Work));
137139
});
138140
}

0 commit comments

Comments
 (0)