[PATCH] D123225: [ThreadPool] add ability to group tasks into separate groups

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 21:28:40 PDT 2022


MaskRay added inline comments.


================
Comment at: llvm/include/llvm/Support/ThreadPool.h:116
 private:
+  typedef std::deque<std::pair<std::function<void()>, ThreadPoolTaskGroup *>>
+      TaskQueue;
----------------
Prefer using


================
Comment at: llvm/include/llvm/Support/ThreadPool.h:166
       assert(EnableFlag && "Queuing a thread during ThreadPool destruction");
-      Tasks.push(std::move(R.first));
+      Tasks.push_back(std::make_pair(std::move(R.first), Group));
       requestedThreads = ActiveThreads + Tasks.size();
----------------
Use `emplace_back`


================
Comment at: llvm/include/llvm/Support/ThreadPool.h:179
     // returned future can be sync'ed on.
-    Tasks.push([Future]() { Future.get(); });
+    Tasks.push_back(std::make_pair([Future]() { Future.get(); }, Group));
     return Future;
----------------
Use `emplace_back`


================
Comment at: llvm/unittests/Support/ThreadPool.cpp:307
+
+  // Task A is run in a first thread, it finishes and leaves
+  // the background thread waiting for more tasks.
----------------
Task A runs in the first thread. It


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123225/new/

https://reviews.llvm.org/D123225



More information about the llvm-commits mailing list