diff --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h --- a/llvm/include/llvm/Support/ThreadPool.h +++ b/llvm/include/llvm/Support/ThreadPool.h @@ -13,6 +13,7 @@ #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/Threading.h" #include "llvm/Support/thread.h" @@ -36,7 +37,7 @@ /// for some work to become available. class ThreadPool { public: - using TaskTy = std::function; + using TaskTy = unique_function; using PackagedTaskTy = std::packaged_task; /// Construct a pool using the hardware strategy \p S for mapping hardware diff --git a/llvm/unittests/Support/ThreadPool.cpp b/llvm/unittests/Support/ThreadPool.cpp --- a/llvm/unittests/Support/ThreadPool.cpp +++ b/llvm/unittests/Support/ThreadPool.cpp @@ -133,6 +133,13 @@ ASSERT_EQ(2, i.load()); } +TEST_F(ThreadPoolTest, NonCopyableTask) { + CHECK_UNSUPPORTED(); + ThreadPool Pool; + Pool.async([P = std::make_unique()] {}); + Pool.wait(); +}; + TEST_F(ThreadPoolTest, GetFuture) { CHECK_UNSUPPORTED(); ThreadPool Pool(hardware_concurrency(2));