bevy/crates/bevy_app/src
Zachary Harrold 99289ad988
Add sleep based on spin to bevy_platform_support (#18633)
# Objective

- Fixes #18617

## Solution

- Added `thread::sleep` to `bevy_platform_support` using a spin-based
fallback.
- Fixed bug in `bevy_platform_support::time::Instant::elapsed`
(comparison was backwards)
- Switched `ScheduleRunnerPlugin` to use
`bevy_platform_support:🧵:sleep` on `std` and `no_std` platforms
(WASM + Browser excluded)

## Testing

- Ran reproduction code from @mockersf in linked issue and confirmed a
consistent 60 counts per `println!`.

---

## Notes

- I chose to add `bevy_platform_support:🧵:sleep` instead of
putting the fix in-line within `ScheduleRunnerPlugin` to keep the
separation of concerns clean. `sleep` is only used in one other location
in Bevy, `bevy_asset`, but I have decided to leave that as-is since
`bevy_asset` isn't `no_std` compatible anyway.
- The bug in `bevy_platform_support::time::Instant::elapsed` wasn't the
cause of this issue, but it did prevent this fix from working so I have
included the it in this PR.
2025-03-31 23:21:49 +00:00
..
app.rs Unify and simplify command and system error handling (#18351) 2025-03-18 19:27:50 +00:00
lib.rs Create new NonSendMarker (#18301) 2025-03-23 21:37:40 +00:00
main_schedule.rs Fix misleading documentation of Main schedule (#18579) 2025-03-28 01:12:19 +00:00
panic_handler.rs Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +00:00
plugin_group.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
plugin.rs Update downcast-rs to version 2 (#17223) 2025-01-07 21:33:40 +00:00
schedule_runner.rs Add sleep based on spin to bevy_platform_support (#18633) 2025-03-31 23:21:49 +00:00
sub_app.rs Unify and simplify command and system error handling (#18351) 2025-03-18 19:27:50 +00:00
task_pool_plugin.rs Create new NonSendMarker (#18301) 2025-03-23 21:37:40 +00:00
terminal_ctrl_c_handler.rs Renamed EventWriter::send methods to write. (#17977) 2025-02-23 21:18:52 +00:00