From faee771b302dc2871e3a91e3797cf1417416ce43 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 20 Oct 2024 22:55:00 +0200 Subject: libstore: hide Worker and goals where possible goals should be considered internal to the worker architecture due to the tight coupling of the two, and we can finally do that. doing this is also a prerequisite for turning Worker::run() into a real promise. Change-Id: I7cf273d4a6fdb75b8d192fce1af07c6265ff6980 --- src/libstore/build/worker.hh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/libstore/build/worker.hh') diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh index e80981876..dc5e0e878 100644 --- a/src/libstore/build/worker.hh +++ b/src/libstore/build/worker.hh @@ -85,9 +85,16 @@ protected: class Worker : public WorkerBase { public: - using Targets = std::map>>; + using Targets = std::vector>>>; struct Results { - std::map goals; + /** Results of individual goals, if available. Goal results will be + * added to this map with the index they had in the `Targets` list + * returned by the goal factory function passed to `work`. If some + * goals did not complete processing, e.g. due to an early exit on + * goal failures, not all indices will be set. This may be used to + * detect which of the goals were cancelled before they completed. + */ + std::map goals; /** * The exit status in case of failure. @@ -217,6 +224,7 @@ public: NotifyingCounter expectedNarSize{[this] { updateStatisticsLater(); }}; NotifyingCounter doneNarSize{[this] { updateStatisticsLater(); }}; +private: Worker(Store & store, Store & evalStore, kj::AsyncIoContext & aio); ~Worker(); @@ -227,7 +235,6 @@ public: /** * @ref DerivationGoal "derivation goal" */ -private: template G> std::pair, kj::Promise>> makeGoalCommon( std::map> & map, @@ -280,6 +287,16 @@ public: bool pathContentsGood(const StorePath & path); void markContentsGood(const StorePath & path); + + template + friend Results + processGoals(Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals); }; +template +Worker::Results +processGoals(Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals) +{ + return Worker(store, evalStore, aio).run(std::forward(mkGoals)); +} } -- cgit v1.2.3