[PATCH] D70447: [Support] ThreadPoolExecutor fixes for Windows/MinGW

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 06:51:38 PST 2020


andrewng marked 5 inline comments as done.
andrewng added inline comments.


================
Comment at: llvm/lib/Support/Parallel.cpp:47
+    Threads.resize(1);
+    std::unique_lock<std::mutex> Lock(Mutex);
+    Threads[0] = std::thread([&, ThreadCount] {
----------------
MaskRay wrote:
> std::lock_guard
I will also change `stop()` and `add()` to use a scoped lock which is actually my preferred style.


================
Comment at: llvm/lib/Support/Parallel.cpp:51
+        Threads.emplace_back([=] { work(); });
+        if (Stop)
+          break;
----------------
MaskRay wrote:
> Why `if (Stop) break`
This is an "early out" in the case that the pool is stopped before all the threads of the pool have been created.


================
Comment at: llvm/lib/Support/Parallel.cpp:74
+      if (T.get_id() == CurrentThreadId)
+        T.detach();
+      else
----------------
MaskRay wrote:
> Why `detach`?
This is to follow the general guideline that a thread should either be detached or joined at exit.


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

https://reviews.llvm.org/D70447





More information about the llvm-commits mailing list