fn prepare_systems<'scope>(
        &mut self,
        scope: &mut Scope<'scope, ()>,
        systems: &'scope mut [ParallelSystemContainer],
        world: &'scope World,
    ) {
        #[cfg(feature = "trace")]
        let span = bevy_utils::tracing::info_span!("prepare_systems");
        #[cfg(feature = "trace")]
        let _guard = span.enter();
        self.should_run.clear();
        for (index, (system_data, system)) in
            self.system_metadata.iter_mut().zip(systems).enumerate()
        {
            // Spawn the system task.
            if system.should_run() {
                self.should_run.set(index, true);
                let start_receiver = system_data.start_receiver.clone();
                let finish_sender = self.finish_sender.clone();
                let system = system.system_mut();
                #[cfg(feature = "trace")] // NB: outside the task to get the TLS current span
                let system_span = bevy_utils::tracing::info_span!("system", name = &*system.name());
                #[cfg(feature = "trace")]
                let overhead_span =
                    bevy_utils::tracing::info_span!("system overhead", name = &*system.name());
                let task = async move {
                    start_receiver
                        .recv()
                        .await
                        .unwrap_or_else(|error| unreachable!(error));
                    #[cfg(feature = "trace")]
                    let system_guard = system_span.enter();
                    unsafe { system.run_unsafe((), world) };
                    #[cfg(feature = "trace")]
                    drop(system_guard);
                    finish_sender
                        .send(index)
                        .await
                        .unwrap_or_else(|error| unreachable!(error));
                };

                #[cfg(feature = "trace")]
                let task = task.instrument(overhead_span);
                if system_data.is_send {
                    scope.spawn(task);
                } else {
                    scope.spawn_local(task);
                }
            }
            // Queue the system if it has no dependencies, otherwise reset its dependency counter.
            if system_data.dependencies_total == 0 {
                self.queued.insert(index);
            } else {
                system_data.dependencies_now = system_data.dependencies_total;
            }
        }
    }
/// Populates `should_run` bitset, spawns tasks for systems that should run this iteration,
/// queues systems with no dependencies to run (or skip) at next opportunity.
Populates `should_run` bitset, spawns tasks for systems that should run this iteration,
queues systems with no dependencies to run (or skip) at next opportunity.
Populates ` should_run ` bitset spawns tasks for systems that should run this iteration queues systems with no dependencies to run ( or skip ) at next opportunity .
fn prepare_systems<'scope>(
        &mut self,
        scope: &mut Scope<'scope, ()>,
        systems: &'scope mut [ParallelSystemContainer],
        world: &'scope World,
    ) {
        #[cfg(feature = "trace")]
        let span = bevy_utils::tracing::info_span!("prepare_systems");
        #[cfg(feature = "trace")]
        let _guard = span.enter();
        self.should_run.clear();
        for (index, (system_data, system)) in
            self.system_metadata.iter_mut().zip(systems).enumerate()
        {
            // Spawn the system task.
            if system.should_run() {
                self.should_run.set(index, true);
                let start_receiver = system_data.start_receiver.clone();
                let finish_sender = self.finish_sender.clone();
                let system = system.system_mut();
                #[cfg(feature = "trace")] // NB: outside the task to get the TLS current span
                let system_span = bevy_utils::tracing::info_span!("system", name = &*system.name());
                #[cfg(feature = "trace")]
                let overhead_span =
                    bevy_utils::tracing::info_span!("system overhead", name = &*system.name());
                let task = async move {
                    start_receiver
                        .recv()
                        .await
                        .unwrap_or_else(|error| unreachable!(error));
                    #[cfg(feature = "trace")]
                    let system_guard = system_span.enter();
                    unsafe { system.run_unsafe((), world) };
                    #[cfg(feature = "trace")]
                    drop(system_guard);
                    finish_sender
                        .send(index)
                        .await
                        .unwrap_or_else(|error| unreachable!(error));
                };
                #[cfg(feature = "trace")]
                let task = task.instrument(overhead_span);
                if system_data.is_send {
                    scope.spawn(task);
                } else {
                    scope.spawn_local(task);
                }
            }
            // Queue the system if it has no dependencies, otherwise reset its dependency counter.
            if system_data.dependencies_total == 0 {
                self.queued.insert(index);
            } else {
                system_data.dependencies_now = system_data.dependencies_total;
            }
        }
    }
fn prepare_systems < ' scope > ( & mut self , scope : & mut Scope < ' scope , ( ) > , systems : & ' scope mut [ ParallelSystemContainer ] , world : & ' scope World , ) { # [ cfg ( feature " " ) ] let span = bevy_utils :: tracing :: info_span ! ( " " ) ; # [ cfg ( feature " " ) ] let _guard = span . enter ( ) ; self . should_run . clear ( ) ; for ( index , ( system_data , system ) ) in self . system_metadata . iter_mut ( ) . zip ( systems ) . enumerate ( ) { // Spawn the system task. if system . should_run ( ) { self . should_run . set ( index , true ) ; let start_receiver = system_data . start_receiver . clone ( ) ; let finish_sender = self . finish_sender . clone ( ) ; let system = system . system_mut ( ) ; # [ cfg ( feature " " ) ] // NB: outside the task to get the TLS current span let system_span = bevy_utils :: tracing :: info_span ! ( " " name system name ( ) ) ; # [ cfg ( feature " " ) ] let overhead_span = bevy_utils :: tracing :: info_span ! ( " " name system name ( ) ) ; let task = async move { start_receiver . recv ( ) . await . unwrap_or_else ( | error | unreachable ! ( error ) ) ; # [ cfg ( feature " " ) ] let system_guard = system_span . enter ( ) ; unsafe { system . run_unsafe ( ( ) , world ) } ; # [ cfg ( feature " " ) ] drop ( system_guard ) ; finish_sender . send ( index ) . await . unwrap_or_else ( | error | unreachable ! ( error ) ) ; } ; # [ cfg ( feature " " ) ] let task = task . instrument ( overhead_span ) ; if system_data . is_send { scope . spawn ( task ) ; } else { scope . spawn_local ( task ) ; } } // Queue the system if it has no dependencies, otherwise reset its dependency counter. if system_data . dependencies_total == 0 { self . queued . insert ( index ) ; } else { system_data . dependencies_now = system_data . dependencies_total ; } } }
Populates `should_run` bitset, spawns tasks for systems that should run this iteration,
queues systems with no dependencies to run (or skip) at next opportunity.
Populates ` should_run ` bitset spawns tasks for systems that should run this iteration queues systems with no dependencies to run ( or skip ) at next opportunity .
&mut self
scope
&mut Scope<'scope, ()>
systems
&'scope mut [ParallelSystemContainer]
world
&'scope World
&mut self
scope
&mut Scope<'scope, ()>
systems
&'scope mut [ParallelSystemContainer]
world
&'scope World