Repository: bevyengine/bevy
File: crates/bevy_time/src/lib.rs (Rust)

Code before:
        }
        None => None,
    };

    match update_strategy.as_ref() {
        TimeUpdateStrategy::Automatic => {
            #[cfg(feature = "std")]
            real_time.update_with_instant(sent_time.unwrap_or_else(Instant::now));

            #[cfg(not(feature = "std"))]
            real_time.update_with_instant(Instant::now());
        }
        TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant),
        TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration),
        TimeUpdateStrategy::FixedTimesteps(factor) => {
            real_time.update_with_duration(fixed_time.timestep() * *factor);
        }
    }

    update_virtual_time(&mut time, &mut virtual_time, &real_time);
}

/// The system used to tick [`DelayedCommandQueue`] timers, which are usually
/// spawned by [`DelayedCommands`]. When the timer finishes, the contained queue
/// is appended to the system's own [`Commands`].
pub fn delayed_queues_system(
    cmds: Query<(Entity, &mut DelayedCommandQueue)>,
    time: Res<Time>,
    mut commands: Commands,
) {
    for (e, mut cmd) in cmds {
        if cmd.timer.tick(time.delta()).just_finished() {
            commands.append(&mut cmd.queue);
            commands.entity(e).despawn();
        }
    }
}

#[cfg(test)]
#[expect(clippy::print_stdout, reason = "Allowed in tests.")]
mod tests {
    use crate::{DelayedCommandsExt, Fixed, Time, TimePlugin, TimeUpdateStrategy, Virtual};
    use bevy_app::{App, FixedUpdate, Startup, Update};
    use bevy_ecs::{
        component::Component,
        message::{
            Message, MessageReader, MessageRegistry, MessageWriter, Messages, ShouldUpdateMessages,
        },
        resource::Resource,
        system::{Commands, Local, Res, ResMut},
    };

Review comment (suggestion):
```suggestion
pub fn tick_delayed_command_queues(
```

We try to avoid adding redundant `_system` names in our system names, and prefer verb-like names that describe the action taken.

Code after:
        }
        None => None,
    };

    match update_strategy.as_ref() {
        TimeUpdateStrategy::Automatic => {
            #[cfg(feature = "std")]
            real_time.update_with_instant(sent_time.unwrap_or_else(Instant::now));

            #[cfg(not(feature = "std"))]
            real_time.update_with_instant(Instant::now());
        }
        TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant),
        TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration),
        TimeUpdateStrategy::FixedTimesteps(factor) => {
            real_time.update_with_duration(fixed_time.timestep() * *factor);
        }
    }

    update_virtual_time(&mut time, &mut virtual_time, &real_time);
}

#[cfg(test)]
#[expect(clippy::print_stdout, reason = "Allowed in tests.")]
mod tests {
    use crate::{Fixed, Time, TimePlugin, TimeUpdateStrategy, Virtual};
    use bevy_app::{App, FixedUpdate, Startup, Update};
    use bevy_ecs::{
        message::{
            Message, MessageReader, MessageRegistry, MessageWriter, Messages, ShouldUpdateMessages,
        },
        resource::Resource,
        system::{Local, Res, ResMut},
    };
    use core::error::Error;
    use core::time::Duration;
    use std::println;

    #[derive(Message)]
    struct TestMessage<T: Default> {
        sender: std::sync::mpsc::Sender<T>,
    }

    impl<T: Default> Drop for TestMessage<T> {
        fn drop(&mut self) {
            self.sender
                .send(T::default())
                .expect("Failed to send drop signal");
        }
    }