pub fn new(job_system: ArcJobSystem, systems: SVec4<BoxedParallelSystemRunner<C, W>>) -> Self {
        if systems.len() > 1 {
            let static_dependency_counts = SVec4::with_capacity(systems.len());

            let static_dependants: SVec4<SVec4<usize>> = (0..systems.len())
                .map(|_| SVec4::<usize>::with_capacity(64))
                .collect();

            let mut dynamic_dependants: SVec4<SVec4<usize>> = repeat(SVec4::with_capacity(64))
                .take(systems.len())
                .collect();

            let mut component_accesses =
                HashMap::<ComponentTypeId, PreviousAccess>::with_capacity_and_hasher(
                    64,
                    Default::default(),
                );

            for (i, system) in systems.iter().enumerate() {
                let read_comp = system.reads();
                let write_comp = system.writes();

                // find component access dependencies
                let mut comp_dependencies = HashSet::<usize>::default();
                for comp in read_comp {
                    let access = component_accesses.entry(*comp).or_default();
                    if let Some(dep) = access.add_read(i) {
                        comp_dependencies.insert(dep);
                    }
                }
                for comp in write_comp {
                    let access = component_accesses.entry(*comp).or_default();
                    for dep in access.add_write(i) {
                        comp_dependencies.insert(dep);
                    }
                }

                for dep in comp_dependencies {
                    if dep != i {
                        // dont be dependent on ourselves
                        dynamic_dependants[dep].push(i);
                    }
                }
            }

            let mut awaiting = SVec4::with_capacity(systems.len());
            systems
                .iter()
                .for_each(|_| awaiting.push(AtomicUsize::new(0)));

            EcsSystemExecutor {
                awaiting,
                static_dependants,
                dynamic_dependants,
                static_dependency_counts,
                systems: systems
                    .into_iter()
                    .map(|s| ParallelSystemBox(UnsafeCell::new(s)))
                    .collect(),
                job_system,
            }
        } else {
            EcsSystemExecutor {
                awaiting: SVec4::with_capacity(0),
                static_dependants: SVec4::with_capacity(0),
                dynamic_dependants: SVec4::with_capacity(0),
                static_dependency_counts: SVec4::with_capacity(0),
                systems: systems
                    .into_iter()
                    .map(|s| ParallelSystemBox(UnsafeCell::new(s)))
                    .collect(),
                job_system,
            }
        }
    }
/// Constructs a new executor for all systems to be run in a single stage.
///
/// Systems are provided in the order in which side-effects (e.g. writes to resources or
/// entities) are to be observed.
// TODO: we should break this up
Constructs a new executor for all systems to be run in a single stage.
Systems are provided in the order in which side-effects  are to be observed.
TODO: we should break this up
Constructs a new executor for all systems to be run in a single stage . Systems are provided in the order in which side - effects are to be observed . TODO : we should break this up
pub fn new(job_system: ArcJobSystem, systems: SVec4<BoxedParallelSystemRunner<C, W>>) -> Self {
        if systems.len() > 1 {
            let static_dependency_counts = SVec4::with_capacity(systems.len());
            let static_dependants: SVec4<SVec4<usize>> = (0..systems.len())
                .map(|_| SVec4::<usize>::with_capacity(64))
                .collect();
            let mut dynamic_dependants: SVec4<SVec4<usize>> = repeat(SVec4::with_capacity(64))
                .take(systems.len())
                .collect();
            let mut component_accesses =
                HashMap::<ComponentTypeId, PreviousAccess>::with_capacity_and_hasher(
                    64,
                    Default::default(),
                );
            for (i, system) in systems.iter().enumerate() {
                let read_comp = system.reads();
                let write_comp = system.writes();
                // find component access dependencies
                let mut comp_dependencies = HashSet::<usize>::default();
                for comp in read_comp {
                    let access = component_accesses.entry(*comp).or_default();
                    if let Some(dep) = access.add_read(i) {
                        comp_dependencies.insert(dep);
                    }
                }
                for comp in write_comp {
                    let access = component_accesses.entry(*comp).or_default();
                    for dep in access.add_write(i) {
                        comp_dependencies.insert(dep);
                    }
                }
                for dep in comp_dependencies {
                    if dep != i {
                        // dont be dependent on ourselves
                        dynamic_dependants[dep].push(i);
                    }
                }
            }
            let mut awaiting = SVec4::with_capacity(systems.len());
            systems
                .iter()
                .for_each(|_| awaiting.push(AtomicUsize::new(0)));
            EcsSystemExecutor {
                awaiting,
                static_dependants,
                dynamic_dependants,
                static_dependency_counts,
                systems: systems
                    .into_iter()
                    .map(|s| ParallelSystemBox(UnsafeCell::new(s)))
                    .collect(),
                job_system,
            }
        } else {
            EcsSystemExecutor {
                awaiting: SVec4::with_capacity(0),
                static_dependants: SVec4::with_capacity(0),
                dynamic_dependants: SVec4::with_capacity(0),
                static_dependency_counts: SVec4::with_capacity(0),
                systems: systems
                    .into_iter()
                    .map(|s| ParallelSystemBox(UnsafeCell::new(s)))
                    .collect(),
                job_system,
            }
        }
    }
pub fn new ( job_system : ArcJobSystem , systems : SVec4 < BoxedParallelSystemRunner < C , W > > ) -> Self { if systems . len ( ) > 1 { let static_dependency_counts = SVec4 :: with_capacity ( systems . len ( ) ) ; let static_dependants : SVec4 < SVec4 < usize > > = ( 0 .. systems . len ( ) ) . map ( | _ | SVec4 :: < usize > :: with_capacity ( 64 ) ) . collect ( ) ; let mut dynamic_dependants : SVec4 < SVec4 < usize > > = repeat ( SVec4 :: with_capacity ( 64 ) ) . take ( systems . len ( ) ) . collect ( ) ; let mut component_accesses = HashMap :: < ComponentTypeId , PreviousAccess > :: with_capacity_and_hasher ( 64 , Default :: default ( ) , ) ; for ( i , system ) in systems . iter ( ) . enumerate ( ) { let read_comp = system . reads ( ) ; let write_comp = system . writes ( ) ; // find component access dependencies let mut comp_dependencies = HashSet :: < usize > :: default ( ) ; for comp in read_comp { let access = component_accesses . entry ( * comp ) . or_default ( ) ; if let Some ( dep ) = access . add_read ( i ) { comp_dependencies . insert ( dep ) ; } } for comp in write_comp { let access = component_accesses . entry ( * comp ) . or_default ( ) ; for dep in access . add_write ( i ) { comp_dependencies . insert ( dep ) ; } } for dep in comp_dependencies { if dep != i { // dont be dependent on ourselves dynamic_dependants [ dep ] . push ( i ) ; } } } let mut awaiting = SVec4 :: with_capacity ( systems . len ( ) ) ; systems . iter ( ) . for_each ( | _ | awaiting . push ( AtomicUsize :: new ( 0 ) ) ) ; EcsSystemExecutor { awaiting , static_dependants , dynamic_dependants , static_dependency_counts , systems : systems . into_iter ( ) . map ( | s | ParallelSystemBox ( UnsafeCell :: new ( s ) ) ) . collect ( ) , job_system , } } else { EcsSystemExecutor { awaiting : SVec4 :: with_capacity ( 0 ) , static_dependants : SVec4 :: with_capacity ( 0 ) , dynamic_dependants : SVec4 :: with_capacity ( 0 ) , static_dependency_counts : SVec4 :: with_capacity ( 0 ) , systems : systems . into_iter ( ) . map ( | s | ParallelSystemBox ( UnsafeCell :: new ( s ) ) ) . collect ( ) , job_system , } } }
Constructs a new executor for all systems to be run in a single stage.
Constructs a new executor for all systems to be run in a single stage .
job_system
ArcJobSystem
systems
SVec4<BoxedParallelSystemRunner<C, W>>
job_system
ArcJobSystem
systems
SVec4<BoxedParallelSystemRunner<C, W>>