pub struct ParallelOrchestrator { /* private fields */ }Expand description
Orchestrates the execution of multiple solver stages respecting dependencies.
§Example
use oxiphysics_core::parallel_orchestrator::{ParallelOrchestrator, SolverStage};
struct SimpleStage { name: String, cost: f64, step_count: u64 }
impl SolverStage for SimpleStage {
fn name(&self) -> &str { &self.name }
fn step(&mut self, _dt: f64) { self.step_count += 1; }
fn estimated_cost(&self) -> f64 { self.cost }
}
let mut orch = ParallelOrchestrator::new();
let a = orch.add_stage("broadphase", &[]);
let b = orch.add_stage("narrowphase", &[a]);
let c = orch.add_stage("solver", &[b]);
let mut stages: Vec<Box<dyn SolverStage>> = vec![
Box::new(SimpleStage { name: "broadphase".into(), cost: 1.0, step_count: 0 }),
Box::new(SimpleStage { name: "narrowphase".into(), cost: 2.0, step_count: 0 }),
Box::new(SimpleStage { name: "solver".into(), cost: 3.0, step_count: 0 }),
];
orch.execute(&mut stages, 0.016).expect("execution failed");Implementations§
Source§impl ParallelOrchestrator
impl ParallelOrchestrator
Sourcepub fn add_stage(&mut self, name: &str, depends_on: &[usize]) -> usize
pub fn add_stage(&mut self, name: &str, depends_on: &[usize]) -> usize
Registers a new stage with the given name and dependency list.
Returns the index of the newly added stage, which can be used as a dependency for later stages.
§Arguments
name- Human-readable stage name.depends_on- Indices of stages that must run before this one.
Sourcepub fn num_stages(&self) -> usize
pub fn num_stages(&self) -> usize
Returns the number of registered stages.
Sourcepub fn stage_names(&self) -> &[String]
pub fn stage_names(&self) -> &[String]
Returns the registered stage names.
Sourcepub fn compute_schedule(&self) -> Result<PipelineSchedule, OrchestratorError>
pub fn compute_schedule(&self) -> Result<PipelineSchedule, OrchestratorError>
Computes a PipelineSchedule by topologically sorting stages into waves.
Returns an error if the dependency graph contains a cycle or references an invalid stage index.
Sourcepub fn execute(
&mut self,
stages: &mut [Box<dyn SolverStage>],
dt: f64,
) -> Result<(), OrchestratorError>
pub fn execute( &mut self, stages: &mut [Box<dyn SolverStage>], dt: f64, ) -> Result<(), OrchestratorError>
Executes all registered stages in dependency order.
Stages within the same wave are currently run sequentially. The timings
for each stage are accumulated across repeated calls to execute.
§Errors
Returns an error if scheduling fails (cycle or invalid index) or if a
scheduled stage index is out of range for the provided stages slice.
Sourcepub fn total_time(&self) -> f64
pub fn total_time(&self) -> f64
Returns the total accumulated wall-clock time across all stages.
Sourcepub fn reset_timings(&mut self)
pub fn reset_timings(&mut self)
Resets all accumulated timings to zero.
Trait Implementations§
Source§impl Clone for ParallelOrchestrator
impl Clone for ParallelOrchestrator
Source§fn clone(&self) -> ParallelOrchestrator
fn clone(&self) -> ParallelOrchestrator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParallelOrchestrator
impl Debug for ParallelOrchestrator
Auto Trait Implementations§
impl Freeze for ParallelOrchestrator
impl RefUnwindSafe for ParallelOrchestrator
impl Send for ParallelOrchestrator
impl Sync for ParallelOrchestrator
impl Unpin for ParallelOrchestrator
impl UnsafeUnpin for ParallelOrchestrator
impl UnwindSafe for ParallelOrchestrator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.