bevy/crates/bevy_window/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
..
event.rs Fix a few typos (#17292) 2025-01-10 22:48:30 +00:00
lib.rs Move spin to bevy_platform_support out of other crates (#17470) 2025-01-23 05:27:02 +00:00
monitor.rs Add no_std support to bevy_window (#17031) 2025-01-01 23:05:25 +00:00
raw_handle.rs Move spin to bevy_platform_support out of other crates (#17470) 2025-01-23 05:27:02 +00:00
system_cursor.rs Add no_std support to bevy_window (#17031) 2025-01-01 23:05:25 +00:00
system.rs Add no_std support to bevy_window (#17031) 2025-01-01 23:05:25 +00:00
window.rs feat: support for clip children on windows (#16545) 2025-01-14 22:22:20 +00:00