From 5f1344dd8aec59ce654a0fac30b1842e2e68299c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 20 Oct 2024 22:55:00 +0200 Subject: 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 --- src/libstore/build/worker.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libstore/build/worker.cc') diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 1cb4a6090..2a764b193 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -229,8 +229,8 @@ try { co_return result::failure(std::current_exception()); } -Worker::Results Worker::run(std::function req) -{ +kj::Promise> Worker::run(std::function req) +try { auto topGoals = req(goalFactory()); assert(!running); @@ -252,7 +252,9 @@ Worker::Results Worker::run(std::function req) promise = promise.exclusiveJoin(boopGC(*localStore)); } - return promise.wait(aio.waitScope).value(); + co_return co_await promise; +} catch (...) { + co_return result::failure(std::current_exception()); } kj::Promise> Worker::runImpl(Targets topGoals) -- cgit v1.2.3