Skip to content

Commit

Permalink
Use elapsed() method on Instant in examples/async_tasks/async_compute…
Browse files Browse the repository at this point in the history
….rs (#4497)

# Objective

Make the example a tiny bit more elegant

## Solution

Change one line

---

## Changelog

> This section is optional. If this was a trivial fix, or has no externally-visible impact, feel free to skip this section.

- What changed as a result of this PR?
- If applicable, organize changes under "Added", "Changed", or "Fixed" sub-headings
- Stick to one or two sentences. If more detail is needed for a particular change, consider adding it to the "Solution" section
  - If you can't summarize the work, your change may be unreasonably large / unrelated. Consider splitting your PR to make it easier to review and merge!

## Migration Guide

> This section is optional

- If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes
- Simply adding new functionality is not a breaking change.
- Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change.
  • Loading branch information
agluszak committed Apr 16, 2022
1 parent 83c6ffb commit ecd23c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/async_tasks/async_compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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

0 comments on commit ecd23c2

Please sign in to comment.