bevy/crates/bevy_app/src
Joshua Holmes 8d9f948684
Create new NonSendMarker (#18301)
# Objective

Create new `NonSendMarker` that does not depend on `NonSend`.

Required, in order to accomplish #17682. In that issue, we are trying to
replace `!Send` resources with `thread_local!` in order to unblock the
resources-as-components effort. However, when we remove all the `!Send`
resources from a system, that allows the system to run on a thread other
than the main thread, which is against the design of the system. So this
marker gives us the control to require a system to run on the main
thread without depending on `!Send` resources.

## Solution

Create a new `NonSendMarker` to replace the existing one that does not
depend on `NonSend`.

## Testing

Other than running tests, I ran a few examples:
- `window_resizing`
- `wireframe`
- `volumetric_fog` (looks so cool)
- `rotation`
- `button`

There is a Mac/iOS-specific change and I do not have a Mac or iOS device
to test it. I am doubtful that it would cause any problems for 2
reasons:
1. The change is the same as the non-wasm change which I did test
2. The Pixel Eagle tests run Mac tests

But it wouldn't hurt if someone wanted to spin up an example that
utilizes the `bevy_render` crate, which is where the Mac/iSO change was.

## Migration Guide

If `NonSendMarker` is being used from `bevy_app::prelude::*`, replace it
with `bevy_ecs::system::NonSendMarker` or use it from
`bevy_ecs::prelude::*`. In addition to that, `NonSendMarker` does not
need to be wrapped like so:
```rust
fn my_system(_non_send_marker: Option<NonSend<NonSendMarker>>) {
    ...
}
```

Instead, it can be used without any wrappers:
```rust
fn my_system(_non_send_marker: NonSendMarker) {
    ...
}
```

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-03-23 21:37:40 +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 Generic system config (#17962) 2025-03-12 00:12:30 +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 Support for non-browser wasm (#17499) 2025-03-07 21:22:28 +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