Skip to content

Commit

Permalink
reorder types closer to time_system where they're used
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Jun 6, 2022
1 parent 452df6e commit 097abcc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions crates/bevy_time/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@ use bevy_ecs::system::{Local, Res, ResMut};
use bevy_utils::{tracing::warn, Duration, Instant};
use crossbeam_channel::{Receiver, Sender};

/// channel resource used to receive time from render world
pub struct TimeReceiver(pub Receiver<Instant>);
/// channel resource used to send time from render world
pub struct TimeSender(pub Sender<Instant>);

/// create channels used for sending time between render world and app world
pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
// bound the channel to 2 since when pipelined the render phase can finish before
// the time system runs.
let (s, r) = crossbeam_channel::bounded::<Instant>(2);
(TimeSender(s), TimeReceiver(r))
}

/// Tracks elapsed time since the last update and since the App has started
#[derive(Debug, Clone)]
pub struct Time {
Expand Down Expand Up @@ -157,6 +144,19 @@ impl Time {
}
}

/// channel resource used to receive time from render world
pub struct TimeReceiver(pub Receiver<Instant>);
/// channel resource used to send time from render world
pub struct TimeSender(pub Sender<Instant>);

/// create channels used for sending time between render world and app world
pub fn create_time_channels() -> (TimeSender, TimeReceiver) {
// bound the channel to 2 since when pipelined the render phase can finish before
// the time system runs.
let (s, r) = crossbeam_channel::bounded::<Instant>(2);
(TimeSender(s), TimeReceiver(r))
}

/// The system used to update the time. If there is a render world the time is sent from
/// there to this system through channels. Otherwise the time is updated in this system.
pub(crate) fn time_system(
Expand Down

0 comments on commit 097abcc

Please sign in to comment.