bevy/crates/bevy_tasks/src
Zachary Harrold 04990fcd27
Move spin to bevy_platform_support out of other crates (#17470)
# Objective

- Contributes to #16877

## Solution

- Expanded `bevy_platform_support::sync` module to provide
API-compatible replacements for `std` items such as `RwLock`, `Mutex`,
and `OnceLock`.
- Removed `spin` from all crates except `bevy_platform_support`.

## Testing

- CI

---

## Notes

- The sync primitives, while verbose, entirely rely on `spin` for their
implementation requiring no `unsafe` and not changing the status-quo on
_how_ locks actually work within Bevy. This is just a refactoring to
consolidate the "hacks" and workarounds required to get a consistent
experience when either using `std::sync` or `spin`.
- I have opted to rely on `std::sync` for `std` compatible locks,
maintaining the status quo. However, now that we have these locks
factored out into the own module, it would be trivial to investigate
alternate locking backends, such as `parking_lot`.
- API for these locking types is entirely based on `std`. I have
implemented methods and types which aren't currently in use within Bevy
(e.g., `LazyLock` and `Once`) for the sake of completeness. As the
standard library is highly stable, I don't expect the Bevy and `std`
implementations to drift apart much if at all.

---------

Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
Co-authored-by: Benjamin Brienen <benjamin.brienen@outlook.com>
2025-01-23 05:27:02 +00:00
..
iter Add no_std support to bevy_tasks (#15464) 2024-12-06 02:14:54 +00:00
executor.rs bevy_tasks: Apply #[deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17089) 2025-01-02 22:42:25 +00:00
futures.rs Move futures.rs, ConditionalSend and BoxedFuture types to bevy_tasks (#16951) 2024-12-29 19:29:53 +00:00
lib.rs Move #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] to the workspace Cargo.toml (#17374) 2025-01-15 01:14:58 +00:00
single_threaded_task_pool.rs Move spin to bevy_platform_support out of other crates (#17470) 2025-01-23 05:27:02 +00:00
slice.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
task_pool.rs Create bevy_platform_support Crate (#17250) 2025-01-20 20:45:30 +00:00
task.rs Fix no_std CI Warnings and WASM Compatibility (#17049) 2024-12-30 23:01:27 +00:00
thread_executor.rs Fix no_std CI Warnings and WASM Compatibility (#17049) 2024-12-30 23:01:27 +00:00
usages.rs Move spin to bevy_platform_support out of other crates (#17470) 2025-01-23 05:27:02 +00:00
wasm_task.rs Fix no_std CI Warnings and WASM Compatibility (#17049) 2024-12-30 23:01:27 +00:00