[PATCH] D145101: [clang][deps] NFC: Simplify worker loop

Ben Langmuir via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 1 12:09:11 PST 2023


benlangmuir added inline comments.


================
Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:802
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I) {
-    Pool.async([I, &Lock, &Index, &Inputs, &HadErrors, &FD, &PD, &WorkerTools,
-                &DependencyOS, &Errs]() {
+    Pool.async([&, I]() {
       llvm::StringSet<> AlreadySeenModules;
----------------
Why are we second-guessing the `ThreadPool` at all? I would think we should do

```
for (unsigned Index = 0; E = Inputs.size(); Index + E; ++Index) {
  Pool.async([Index, &]{ ... });
}
```

Then the thread pool is responsible for dispatching the tasks when it has available resources instead of us manually looping inside the threads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145101



More information about the cfe-commits mailing list