Loading...
Searching...
No Matches
eonc::Job Class Referenceabstract

Declaration of job class. More...

#include <Job.h>

Inheritance diagram for eonc::Job:

Classes

struct  ExclusivePotential
 Point and Minimization keep ownedPot. Other jobs share in the public ctor. More...

Public Member Functions

void adoptRuntime (std::unique_ptr< Runtime > rt)
 Take ownership of a Runtime previously passed as Runtime&.
 Job (std::unique_ptr< Parameters > parameters, Runtime &rt)
 Borrow: caller keeps Runtime alive (CLI stack / Python Session).
 Job (std::unique_ptr< Parameters > parameters, std::unique_ptr< Runtime > rt)
 Own a Runtime (one-shot makeJob / rvalue).
 Job (std::unique_ptr< Parameters > parameters)
 Own a default-constructed Runtime.
 Job (std::shared_ptr< Potential > potPassed, const Parameters &parameters)
virtual ~Job ()=default
virtual std::vector< std::string > run ()=0
 Virtual run; used solely for dynamic dispatch.
JobType getType ()
PotRegistry & pots () noexcept
size_t potRegistryForceCalls () const noexcept
 Force calls charged to pot's registry.
void releasePotential ()
 Drop the Potential so on_destroyed is recorded before Runtime dies.

Protected Member Functions

 Job (std::unique_ptr< Parameters > parameters, Runtime &rt, ExclusivePotential)

Protected Attributes

JobType jtype
Parameters params
std::unique_ptr< Runtime > owned_runtime_
 Non-null when this Job owns the composition root (one-shot makeJob).
Runtime * runtime_
 Always valid: either owned_runtime_.get() or a caller-owned Runtime.
std::unique_ptr< Potential > ownedPot
 Exclusive until a multi-owner job promotes it in the public constructor.
std::shared_ptr< Potential > pot
 Set when one Potential is shared across Matters, images, or a caller.

Detailed Description

Declaration of job class.

Definition at line 53 of file Job.h.

Constructor & Destructor Documentation

◆ Job() [1/5]

eonc::Job::Job ( std::unique_ptr< Parameters > parameters,
Runtime & rt,
ExclusivePotential  )
inlineprotected

Definition at line 71 of file Job.h.

72 : jtype{parameters->main_options().job}, params{*std::move(parameters)},
74 ownedPot{helpers::makePotential(params.potential_options().potential,
75 params, rt)} {}
std::unique_ptr< Runtime > owned_runtime_
Non-null when this Job owns the composition root (one-shot makeJob).
Definition Job.h:60
JobType jtype
Definition Job.h:57
Parameters params
Definition Job.h:58
Runtime * runtime_
Always valid: either owned_runtime_.get() or a caller-owned Runtime.
Definition Job.h:62
std::unique_ptr< Potential > ownedPot
Exclusive until a multi-owner job promotes it in the public constructor.
Definition Job.h:64
std::unique_ptr< Potential > makePotential(const Parameters &params)
Exclusive ownership.

◆ Job() [2/5]

eonc::Job::Job ( std::unique_ptr< Parameters > parameters,
Runtime & rt )
inline

Borrow: caller keeps Runtime alive (CLI stack / Python Session).

The potential is shared. Point and minimization use ExclusivePotential.

Definition at line 89 of file Job.h.

90 : Job(std::move(parameters), rt, ExclusivePotential{}) {
92 }
Job(std::unique_ptr< Parameters > parameters, Runtime &rt, ExclusivePotential)
Definition Job.h:71
std::shared_ptr< Potential > pot
Set when one Potential is shared across Matters, images, or a caller.
Definition Job.h:66
std::shared_ptr< Potential > sharePotential(std::unique_ptr< Potential > pot)
Multi-owner boundary: one instance observed by several Matters, images, or a binding.
Definition Potential.h:292
Point and Minimization keep ownedPot. Other jobs share in the public ctor.
Definition Job.h:69

◆ Job() [3/5]

eonc::Job::Job ( std::unique_ptr< Parameters > parameters,
std::unique_ptr< Runtime > rt )
inline

Own a Runtime (one-shot makeJob / rvalue).

Definition at line 94 of file Job.h.

95 : Job(std::move(parameters), *rt) {
96 adoptRuntime(std::move(rt));
97 }
void adoptRuntime(std::unique_ptr< Runtime > rt)
Take ownership of a Runtime previously passed as Runtime&.
Definition Job.h:79

◆ Job() [4/5]

eonc::Job::Job ( std::unique_ptr< Parameters > parameters)
inlineexplicit

Own a default-constructed Runtime.

Definition at line 99 of file Job.h.

100 : Job(std::move(parameters), std::make_unique<Runtime>()) {}

◆ Job() [5/5]

eonc::Job::Job ( std::shared_ptr< Potential > potPassed,
const Parameters & parameters )
inline

Definition at line 101 of file Job.h.

102 : jtype{parameters.main_options().job}, params{parameters},
103 owned_runtime_{std::make_unique<Runtime>()},
104 runtime_{owned_runtime_.get()}, pot{std::move(potPassed)} {}
const main_options_t & main_options() const

◆ ~Job()

virtual eonc::Job::~Job ( )
virtualdefault

Member Function Documentation

◆ adoptRuntime()

void eonc::Job::adoptRuntime ( std::unique_ptr< Runtime > rt)
inline

Take ownership of a Runtime previously passed as Runtime&.

Definition at line 79 of file Job.h.

79 {
80 if (!rt || runtime_ != rt.get()) {
81 throw std::logic_error(
82 "Job::adoptRuntime: Runtime is not the borrowed instance");
83 }
84 owned_runtime_ = std::move(rt);
85 }

◆ getType()

JobType eonc::Job::getType ( )
inlinenodiscard

Definition at line 108 of file Job.h.

108{ return this->jtype; };

◆ potRegistryForceCalls()

size_t eonc::Job::potRegistryForceCalls ( ) const
nodiscardnoexcept

Force calls charged to pot's registry.

Per-image clones of pot (Main.parallel) charge it too; pot->forceCallCounter sees only pot.

Definition at line 44 of file Job.cpp.

44 {
45 if (const auto *registry =
46 dynamic_cast<const PotRegistry *>(&pot->registry())) {
47 return registry->total_force_calls();
48 }
49 return pot->forceCallCounter;
50}

◆ pots()

PotRegistry & eonc::Job::pots ( )
inlinenodiscardnoexcept

Definition at line 109 of file Job.h.

109{ return runtime_->pots(); }

◆ releasePotential()

void eonc::Job::releasePotential ( )
inline

Drop the Potential so on_destroyed is recorded before Runtime dies.

Definition at line 114 of file Job.h.

114{ pot.reset(); }

◆ run()

Member Data Documentation

◆ jtype

JobType eonc::Job::jtype
protected

Definition at line 57 of file Job.h.

◆ owned_runtime_

std::unique_ptr<Runtime> eonc::Job::owned_runtime_
protected

Non-null when this Job owns the composition root (one-shot makeJob).

Definition at line 60 of file Job.h.

◆ ownedPot

std::unique_ptr<Potential> eonc::Job::ownedPot
protected

Exclusive until a multi-owner job promotes it in the public constructor.

Definition at line 64 of file Job.h.

◆ params

Parameters eonc::Job::params
protected

Definition at line 58 of file Job.h.

◆ pot

std::shared_ptr<Potential> eonc::Job::pot
protected

Set when one Potential is shared across Matters, images, or a caller.

Definition at line 66 of file Job.h.

◆ runtime_

Runtime* eonc::Job::runtime_
protected

Always valid: either owned_runtime_.get() or a caller-owned Runtime.

Definition at line 62 of file Job.h.


The documentation for this class was generated from the following files:
  • /home/runner/work/eOn/eOn/include/eon/Job.h
  • /home/runner/work/eOn/eOn/client/Job.cpp