[PATCH] D79685: [Support] Use unique_function for ThreadPool.

Lang Hames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 9 22:20:10 PDT 2020


lhames created this revision.
lhames added a reviewer: mehdi_amini.
Herald added a subscriber: ributzka.
Herald added a project: LLVM.

This allows move-only function objects (including lambdas that capture move-only
objects) to be passed to a ThreadPool instance for execution.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79685

Files:
  llvm/include/llvm/Support/ThreadPool.h


Index: llvm/include/llvm/Support/ThreadPool.h
===================================================================
--- llvm/include/llvm/Support/ThreadPool.h
+++ llvm/include/llvm/Support/ThreadPool.h
@@ -14,6 +14,7 @@
 #define LLVM_SUPPORT_THREAD_POOL_H
 
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/FunctionExtras.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/thread.h"
@@ -37,7 +38,7 @@
 /// for some work to become available.
 class ThreadPool {
 public:
-  using TaskTy = std::function<void()>;
+  using TaskTy = unique_function<void()>;
   using PackagedTaskTy = std::packaged_task<void()>;
 
   /// Construct a pool using the hardware strategy \p S for mapping hardware


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79685.263059.patch
Type: text/x-patch
Size: 741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200510/213d7bc0/attachment.bin>


More information about the llvm-commits mailing list