21typedef std::weak_ptr<Goal> WeakGoalPtr;
30typedef std::set<GoalPtr, CompareGoalPtrs>
Goals;
31typedef std::set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
55struct Goal :
public std::enable_shared_from_this<Goal>
57 typedef enum {ecBusy, ecSuccess, ecFailed, ecNoSubstituters, ecIncompleteClosure} ExitCode;
126 struct [[nodiscard]] Done {
182 struct [[nodiscard]] Co {
189 void operator=(
Co&&);
193 bool await_ready() {
return false; };
206 std::coroutine_handle<> await_suspend(handle_type handle);
207 void await_resume() {};
221 bool await_ready() {
return false; };
225 void await_resume() {
227 assert(
handle.promise().goal);
228 assert(
handle.promise().goal->top_co);
229 assert(
handle.promise().goal->top_co->handle ==
handle);
260 bool await_ready()
noexcept {
return false; };
268 void await_resume()
noexcept { assert(
false); };
360 Done amDone(ExitCode result, std::optional<Error>
ex = {});
362 virtual void cleanup() { }
379 std::optional<Error>
ex;
385 assert(!
top_co->handle.promise().goal);
387 top_co->handle.promise().goal =
this;
392 trace(
"goal destroyed");
397 void addWaitee(GoalPtr waitee);
399 virtual void waiteeDone(GoalPtr waitee, ExitCode result);
401 virtual void handleChildOutput(Descriptor
fd, std::string_view
data)
406 virtual void handleEOF(Descriptor
fd)
411 void trace(std::string_view
s);
413 std::string getName()
const
425 virtual std::string key() = 0;
434void addToWeakGoals(WeakGoals & goals,
GoalPtr p);
438template<
typename... ArgTypes>
439struct std::coroutine_traits<nix::Goal::Co, ArgTypes...> {
JobCategory
Definition goal.hh:44
@ Substitution
Definition goal.hh:52
@ Build
Definition goal.hh:48
std::shared_ptr< Goal > GoalPtr
Definition goal.hh:20
std::set< GoalPtr, CompareGoalPtrs > Goals
Definition goal.hh:30
std::map< StorePath, WeakGoalPtr > WeakGoalMap
Definition goal.hh:36
return s
Definition lexer.l:459
std::shared_ptr< T > p
Definition lexer.l:1269
std::variant< std::string, std::string_view > data
Definition lexer.l:177
return fd
Definition lexer.l:2948
Definition build-result.hh:14
Definition derived-path.hh:229
handle_type handle
Definition goal.hh:186
handle_type handle
Definition goal.hh:219
std::coroutine_handle await_suspend(handle_type h) noexcept
Definition goal.cc:31
void return_value(Return)
Definition goal.hh:294
Goal * goal
Definition goal.hh:248
void return_value(Done)
Definition goal.hh:300
Co && await_transform(Co &&co)
Definition goal.hh:326
void unhandled_exception()
Definition goal.hh:321
InitialSuspend initial_suspend()
Definition goal.hh:282
std::optional< Co > continuation
Definition goal.hh:242
std::suspend_always await_transform(Suspend)
Definition goal.hh:332
Co get_return_object()
Definition goal.cc:26
final_awaiter final_suspend() noexcept
Definition goal.hh:288
bool alive
Definition goal.hh:254
virtual void timedOut(Error &&ex)=0
BuildResult buildResult
Definition goal.hh:106
size_t nrFailed
Definition goal.hh:78
std::string name
Definition goal.hh:95
std::optional< Error > ex
Definition goal.hh:379
std::optional< Co > top_co
Definition goal.hh:342
virtual JobCategory jobCategory() const =0
Hint for the scheduler, which concurrency limit applies.
Co init_wrapper()
Definition goal.hh:443
Goals waitees
Definition goal.hh:67
std::coroutine_handle< promise_type > handle_type
Definition goal.hh:139
ExitCode exitCode
Definition goal.hh:100
size_t nrIncompleteClosure
Definition goal.hh:90
size_t nrNoSubstituters
Definition goal.hh:84
Done amDone(ExitCode result, std::optional< Error > ex={})
Definition goal.cc:169
Worker & worker
Definition goal.hh:62
WeakGoals waiters
Definition goal.hh:73
BuildResult getBuildResult(const DerivedPath &) const
Definition goal.cc:105