aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/worker.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-10-20 22:55:00 +0200
committereldritch horrors <pennae@lix.systems>2024-10-23 11:55:12 +0000
commitfaee771b302dc2871e3a91e3797cf1417416ce43 (patch)
treea6a027dc9a912979d33089e7efb76a8c71938214 /src/libstore/build/worker.hh
parentb8cc54df0a7748e1af5b2f0acbf548c5bcab6f56 (diff)
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
Diffstat (limited to 'src/libstore/build/worker.hh')
-rw-r--r--src/libstore/build/worker.hh23
1 files changed, 20 insertions, 3 deletions
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<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>;
+ using Targets = std::vector<std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>>;
struct Results {
- std::map<GoalPtr, Goal::WorkResult> 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<size_t, Goal::WorkResult> goals;
/**
* The exit status in case of failure.
@@ -217,6 +224,7 @@ public:
NotifyingCounter<uint64_t> expectedNarSize{[this] { updateStatisticsLater(); }};
NotifyingCounter<uint64_t> doneNarSize{[this] { updateStatisticsLater(); }};
+private:
Worker(Store & store, Store & evalStore, kj::AsyncIoContext & aio);
~Worker();
@@ -227,7 +235,6 @@ public:
/**
* @ref DerivationGoal "derivation goal"
*/
-private:
template<typename ID, std::derived_from<Goal> G>
std::pair<std::shared_ptr<G>, kj::Promise<Result<Goal::WorkResult>>> makeGoalCommon(
std::map<ID, CachedGoal<G>> & map,
@@ -280,6 +287,16 @@ public:
bool pathContentsGood(const StorePath & path);
void markContentsGood(const StorePath & path);
+
+ template<typename MkGoals>
+ friend Results
+ processGoals(Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals);
};
+template<typename MkGoals>
+Worker::Results
+processGoals(Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals)
+{
+ return Worker(store, evalStore, aio).run(std::forward<MkGoals>(mkGoals));
+}
}