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
commit5f1344dd8aec59ce654a0fac30b1842e2e68299c (patch)
tree01e1205ec85556983b33ca5bc596703330570071 /src/libstore/build/worker.hh
parentfaee771b302dc2871e3a91e3797cf1417416ce43 (diff)
libstore: turn Worker::run into a promise
a first little step into pushing the event loops up, up and away. eventually we will want them to be instantiated only at the roots of every thread (since kj binds loops to threads), but not today. Change-Id: Ic97f1debba382a5a3f46daeaf2d6d434ee42569f
Diffstat (limited to 'src/libstore/build/worker.hh')
-rw-r--r--src/libstore/build/worker.hh18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/libstore/build/worker.hh b/src/libstore/build/worker.hh
index dc5e0e878..369e58b41 100644
--- a/src/libstore/build/worker.hh
+++ b/src/libstore/build/worker.hh
@@ -278,7 +278,7 @@ public:
/**
* Loop until the specified top-level goals have finished.
*/
- Results run(std::function<Targets (GoalFactory &)> req);
+ kj::Promise<Result<Results>> run(std::function<Targets (GoalFactory &)> req);
/**
* Check whether the given valid path exists and has the right
@@ -289,14 +289,18 @@ public:
void markContentsGood(const StorePath & path);
template<typename MkGoals>
- friend Results
- processGoals(Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals);
+ friend kj::Promise<Result<Results>> processGoals(
+ Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals
+ ) noexcept;
};
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));
+kj::Promise<Result<Worker::Results>> processGoals(
+ Store & store, Store & evalStore, kj::AsyncIoContext & aio, MkGoals && mkGoals
+) noexcept
+try {
+ co_return co_await Worker(store, evalStore, aio).run(std::forward<MkGoals>(mkGoals));
+} catch (...) {
+ co_return result::failure(std::current_exception());
}
}