aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/goal.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-09-24 00:21:16 +0200
committereldritch horrors <pennae@lix.systems>2024-09-27 16:40:27 +0200
commit852da07b67564f7a9986f0638aac391d334d4afa (patch)
tree993d896dd8353a664723206c2f3ea59230f3d1f5 /src/libstore/build/goal.hh
parentbf32085d63ccfa8fb1e0cff2f2ae7156b4679015 (diff)
libstore: replace Goal::WaitForSlot with semaphores
now that we have an event loop in the worker we can use it and its magical execution suspending properties to replace the slot counts we managed explicitly with semaphores and raii tokens. technically this would not have needed an event loop base to be doable, but it is a whole lot easier to wait for a token to be available if there is a callback mechanism ready for use that doesn't require a whole damn dedicated abstract method in Goal to work, and specific calls to that dedicated method strewn all over the worker implementation Change-Id: I1da7cf386d94e2bbf2dba9b53ff51dbce6a0cff7
Diffstat (limited to 'src/libstore/build/goal.hh')
-rw-r--r--src/libstore/build/goal.hh9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index fbf767e8d..1ccf9716b 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -1,6 +1,7 @@
#pragma once
///@file
+#include "async-semaphore.hh"
#include "result.hh"
#include "types.hh"
#include "store-api.hh"
@@ -112,19 +113,20 @@ struct Goal
*/
BuildResult buildResult;
+protected:
+ AsyncSemaphore::Token slotToken;
+
public:
struct Finished;
struct [[nodiscard]] StillAlive {};
- struct [[nodiscard]] WaitForSlot {};
struct [[nodiscard]] ContinueImmediately {};
struct [[nodiscard]] WaitForGoals {
Goals goals;
};
struct [[nodiscard]] WaitForWorld {
kj::Promise<Outcome<void, Finished>> promise;
- bool inBuildSlot;
};
struct [[nodiscard]] Finished {
ExitCode exitCode;
@@ -138,7 +140,6 @@ public:
struct [[nodiscard]] WorkResult : std::variant<
StillAlive,
- WaitForSlot,
ContinueImmediately,
WaitForGoals,
WaitForWorld,
@@ -168,7 +169,7 @@ public:
trace("goal destroyed");
}
- virtual kj::Promise<Result<WorkResult>> work(bool inBuildSlot) noexcept = 0;
+ virtual kj::Promise<Result<WorkResult>> work() noexcept = 0;
virtual void waiteeDone(GoalPtr waitee) { }