From ae5d8dae1b796967c40b1f22b844d07f5697033e Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Tue, 24 Sep 2024 00:21:16 +0200 Subject: libstore: turn Goal::WaitForGoals into a promise also gets rid of explicit strong references to dependencies of any goal, and weak references to dependers as well. those are now only held within promises representing goal completion and thus independent of the goal's relation to each other. the weak references to dependers was only needed for notifications, and that's much better handled entirely by kj itself. Change-Id: I00d06df9090f8d6336ee4bb0c1313a7052fb016b --- src/libstore/build/goal.hh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/libstore/build/goal.hh') diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh index 1ccf9716b..e7a500a00 100644 --- a/src/libstore/build/goal.hh +++ b/src/libstore/build/goal.hh @@ -6,6 +6,7 @@ #include "types.hh" #include "store-api.hh" #include "build-result.hh" +#include // IWYU pragma: keep #include namespace nix { @@ -70,17 +71,6 @@ struct Goal */ const bool isDependency; - /** - * Goals that this goal is waiting for. - */ - Goals waitees; - - /** - * Goals waiting for this one to finish. Must use weak pointers - * here to prevent cycles. - */ - WeakGoals waiters; - /** * Number of goals we are/were waiting for that have failed. */ @@ -113,6 +103,9 @@ struct Goal */ BuildResult buildResult; + // for use by Worker only. will go away once work() is a promise. + kj::Own> notify; + protected: AsyncSemaphore::Token slotToken; @@ -122,9 +115,6 @@ public: struct [[nodiscard]] StillAlive {}; struct [[nodiscard]] ContinueImmediately {}; - struct [[nodiscard]] WaitForGoals { - Goals goals; - }; struct [[nodiscard]] WaitForWorld { kj::Promise> promise; }; @@ -141,7 +131,6 @@ public: struct [[nodiscard]] WorkResult : std::variant< StillAlive, ContinueImmediately, - WaitForGoals, WaitForWorld, Finished> { @@ -151,6 +140,15 @@ public: protected: kj::Promise> waitForAWhile(); + kj::Promise> + waitForGoals(kj::Array>> dependencies) noexcept; + + template... G> + kj::Promise> + waitForGoals(std::pair, kj::Promise>... goals) noexcept + { + return waitForGoals(kj::arrOf>>(std::move(goals)...)); + } public: -- cgit v1.2.3