Skip to content

Commit

Permalink
[Orc] Roll back ThreadPool to std::function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
d0k committed Sep 13, 2019
1 parent 3642ab2 commit e8e4b1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/SpeculativeJIT/SpeculativeJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ class SpeculativeJIT {
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));
Expand Down
3 changes: 1 addition & 2 deletions include/llvm/Support/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/ExecutionEngine/Orc/LLJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}
Expand Down

0 comments on commit e8e4b1e

Please sign in to comment.