[clang] [clang][deps] Ensure the service outlives async module compiles (PR #181772)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 08:43:02 PDT 2026
================
@@ -554,11 +555,42 @@ dependencies::initializeScanInstanceDependencyCollector(
return MDC;
}
+/// Manages (and terminates) the asynchronous compilation of modules.
+class AsyncModuleCompiles {
+ std::mutex Mutex;
+ bool Stop = false;
+ // FIXME: Have the service own a thread pool and use that instead.
+ std::vector<std::thread> Compiles;
+
+public:
+ /// Registers the module compilation, unless this instance is about to be
+ /// destroyed.
+ void add(llvm::unique_function<void()> Compile) {
+ std::lock_guard<std::mutex> Lock(Mutex);
+ if (!Stop)
+ Compiles.emplace_back(std::move(Compile));
+ }
+
+ ~AsyncModuleCompiles() {
----------------
AaronBallman wrote:
FWIW, I think this was [post-commit review feedback](https://llvm.org/docs/CodeReview.html#post-commit-review) we'd generally expect the patch author to address, particularly given the speed at which the PR was posted, accepted, and merged.
https://github.com/llvm/llvm-project/pull/181772
More information about the cfe-commits
mailing list