Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::Goal Struct Referenceabstract
Inheritance diagram for nix::Goal:
nix::DerivationGoal nix::DrvOutputSubstitutionGoal nix::PathSubstitutionGoal

Classes

struct  Co
 
struct  Done
 
struct  InitialSuspend
 
struct  promise_type
 
struct  Return
 
struct  Suspend
 

Public Types

enum  ExitCode {
  ecBusy , ecSuccess , ecFailed , ecNoSubstituters ,
  ecIncompleteClosure
}
 
using handle_type = std::coroutine_handle<promise_type>
 

Public Member Functions

virtual Co init ()=0
 
Co init_wrapper ()
 
Done amDone (ExitCode result, std::optional< Error > ex={})
 
virtual void cleanup ()
 
BuildResult getBuildResult (const DerivedPath &) const
 
 Goal (Worker &worker, DerivedPath path)
 
void work ()
 
void addWaitee (GoalPtr waitee)
 
virtual void waiteeDone (GoalPtr waitee, ExitCode result)
 
virtual void handleChildOutput (Descriptor fd, std::string_view data)
 
virtual void handleEOF (Descriptor fd)
 
void trace (std::string_view s)
 
std::string getName () const
 
virtual void timedOut (Error &&ex)=0
 
virtual std::string key ()=0
 
virtual JobCategory jobCategory () const =0
 Hint for the scheduler, which concurrency limit applies.
 

Public Attributes

Workerworker
 
Goals waitees
 
WeakGoals waiters
 
size_t nrFailed = 0
 
size_t nrNoSubstituters = 0
 
size_t nrIncompleteClosure = 0
 
std::string name
 
ExitCode exitCode = ecBusy
 
std::optional< Cotop_co
 
std::optional< Error > ex
 

Protected Attributes

BuildResult buildResult
 

Member Typedef Documentation

◆ handle_type

using nix::Goal::handle_type = std::coroutine_handle<promise_type>

Handle to coroutine using Co and promise_type.

Member Function Documentation

◆ amDone()

Goal::Done nix::Goal::amDone ( ExitCode result,
std::optional< Error > ex = {} )

Signals that the goal is done. co_return the result. If you're not inside a coroutine, you can ignore the return value safely.

◆ getBuildResult()

BuildResult nix::Goal::getBuildResult ( const DerivedPath & req) const

Project a BuildResult with just the information that pertains to the given request.

In general, goals may be aliased between multiple requests, and the stored BuildResult has information for the union of all requests. We don't want to leak what the other request are for sake of both privacy and determinism, and this "safe accessor" ensures we don't.

◆ handleChildOutput()

virtual void nix::Goal::handleChildOutput ( Descriptor fd,
std::string_view data )
inlinevirtual

◆ init()

virtual Co nix::Goal::init ( )
pure virtual

The entry point for the goal

Implemented in nix::DerivationGoal, nix::DrvOutputSubstitutionGoal, and nix::PathSubstitutionGoal.

◆ init_wrapper()

nix::Goal::Co nix::Goal::init_wrapper ( )
inline

Wrapper around init since virtual functions can't be used in constructors.

◆ jobCategory()

virtual JobCategory nix::Goal::jobCategory ( ) const
pure virtual

Hint for the scheduler, which concurrency limit applies.

See also
JobCategory

Implemented in nix::DerivationGoal, nix::DrvOutputSubstitutionGoal, and nix::PathSubstitutionGoal.

◆ key()

virtual std::string nix::Goal::key ( )
pure virtual

Implemented in nix::PathSubstitutionGoal.

◆ timedOut()

virtual void nix::Goal::timedOut ( Error && ex)
pure virtual

Callback in case of a timeout. It should wake up its waiters, get rid of any running child processes that are being monitored by the worker (important!), etc.

Implemented in nix::DerivationGoal, nix::DrvOutputSubstitutionGoal, and nix::PathSubstitutionGoal.

Member Data Documentation

◆ buildResult

BuildResult nix::Goal::buildResult
protected

Build result.

◆ ex

std::optional<Error> nix::Goal::ex

Exception containing an error message, if any.

◆ exitCode

ExitCode nix::Goal::exitCode = ecBusy

Whether the goal is finished.

◆ name

std::string nix::Goal::name

Name of this goal for debugging purposes.

◆ nrFailed

size_t nix::Goal::nrFailed = 0

Number of goals we are/were waiting for that have failed.

◆ nrIncompleteClosure

size_t nix::Goal::nrIncompleteClosure = 0

Number of substitution goals we are/were waiting for that failed because they had unsubstitutable references.

◆ nrNoSubstituters

size_t nix::Goal::nrNoSubstituters = 0

Number of substitution goals we are/were waiting for that failed because there are no substituters.

◆ top_co

std::optional<Co> nix::Goal::top_co

The coroutine being currently executed. MUST be updated when switching the coroutine being executed. This is used both for memory management and to resume the last coroutine executed. Destroying this should destroy all coroutines created for this goal.

◆ waitees

Goals nix::Goal::waitees

Goals that this goal is waiting for.

◆ waiters

WeakGoals nix::Goal::waiters

Goals waiting for this one to finish. Must use weak pointers here to prevent cycles.

◆ worker

Worker& nix::Goal::worker

Backlink to the worker.


The documentation for this struct was generated from the following files: