================
@@ -152,19 +154,54 @@ using CachedRealPath = llvm::ErrorOr<std::string>;
/// the worker threads.
class DependencyScanningFilesystemSharedCache {
public:
+ /// Tracks a cache entry whose value is currently being computed by one
+ /// worker so that other workers arriving at the same key can wait for the
+ /// result rather than producing it in parallel. The producer publishes the
+ /// resolved entry into \c Result, sets \c Done, and notifies waiters via
+ /// \c CondVar. Waiters synchronize through the owning shard's \c CacheLock.
+ struct InProgressEntry {
+ std::condition_variable CondVar;
+ bool Done = false;
+ const CachedFileSystemEntry *Result = nullptr;
----------------
artemcm wrote:
`Result` does duplicate the value, but it's the one copy a woken waiter can
read without re-taking the shard lock, which I think is still net beneficial,
especially in combination with the above refactor to move away from using the
shard lock on the wait.
https://github.com/llvm/llvm-project/pull/199680
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits