Skip to content

Commit

Permalink
use elapsed on instant (bevyengine#4599)
Browse files Browse the repository at this point in the history
# Objective

- reopen bevyengine#4497 on main
- Make the example a tiny bit more elegant
  • Loading branch information
mockersf authored and ItsDoot committed Feb 1, 2023
1 parent a620724 commit a58195d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/async_tasks/async_compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn spawn_tasks(mut commands: Commands, thread_pool: Res<AsyncComputeTaskPool>) {
let mut rng = rand::thread_rng();
let start_time = Instant::now();
let duration = Duration::from_secs_f32(rng.gen_range(0.05..0.2));
while Instant::now() - start_time < duration {
while start_time.elapsed() < duration {
// Spinning for 'duration', simulating doing hard
// compute work generating translation coords!
}
Expand Down
2 changes: 1 addition & 1 deletion examples/async_tasks/external_source_external_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let mut rng = rand::thread_rng();
let start_time = Instant::now();
let duration = Duration::from_secs_f32(rng.gen_range(0.0..0.2));
while Instant::now() - start_time < duration {
while start_time.elapsed() < duration {
// Spinning for 'duration', simulating doing hard work!
}

Expand Down

0 comments on commit a58195d

Please sign in to comment.