aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/goal.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-07-26 19:24:38 +0200
committereldritch horrors <pennae@lix.systems>2024-08-02 13:52:15 +0000
commitdfcab1c3f09971cba6a198ba81158d1190975165 (patch)
tree36f4287da46b9fae2d864fb6c6d8c30a5240d46a /src/libstore/build/goal.hh
parent724b345eb985404065a930304b82112a80ee92d3 (diff)
libstore: return finishedness from Goal methods
this is the first step towards removing all result-related mutation of Goal state from goal implementations themselves, and into Worker state instead. once that is done we can treat all non-const Goal fields like private state of the goal itself, and make threading of goals possible Change-Id: I69ff7d02a6fd91a65887c6640bfc4f5fb785b45c
Diffstat (limited to 'src/libstore/build/goal.hh')
-rw-r--r--src/libstore/build/goal.hh17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index 575621037..db20b5cdb 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -105,6 +105,15 @@ struct Goal : public std::enable_shared_from_this<Goal>
public:
+ struct StillAlive {};
+ struct Finished {};
+
+ struct WorkResult : std::variant<StillAlive, Finished>
+ {
+ WorkResult() = delete;
+ using variant::variant;
+ };
+
/**
* Exception containing an error message, if any.
*/
@@ -119,13 +128,13 @@ public:
trace("goal destroyed");
}
- virtual void work() = 0;
+ virtual WorkResult work() = 0;
void addWaitee(GoalPtr waitee);
virtual void waiteeDone(GoalPtr waitee, ExitCode result);
- virtual void handleChildOutput(int fd, std::string_view data)
+ virtual WorkResult handleChildOutput(int fd, std::string_view data)
{
abort();
}
@@ -146,11 +155,11 @@ public:
* get rid of any running child processes that are being monitored
* by the worker (important!), etc.
*/
- virtual void timedOut(Error && ex) = 0;
+ virtual Finished timedOut(Error && ex) = 0;
virtual std::string key() = 0;
- void amDone(ExitCode result, std::optional<Error> ex = {});
+ Finished amDone(ExitCode result, std::optional<Error> ex = {});
virtual void cleanup() { }