bevy/crates/bevy_ecs/src/system
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
..
commands Unify and simplify command and system error handling (#18351) 2025-03-18 19:27:50 +00:00
adapter_system.rs Add no_std support to bevy_ecs (#16758) 2024-12-17 21:40:36 +00:00
builder.rs Support using FilteredResources with ReflectResource. (#15624) 2025-02-16 19:56:19 +00:00
combinator.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
exclusive_function_system.rs Recursive run_system (#18076) 2025-03-10 21:38:36 +00:00
exclusive_system_param.rs Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
function_system.rs Improve docs for WorldQuery (#17654) 2025-02-03 22:13:42 +00:00
input.rs bevy_ecs: Apply #![warn(clippy::allow_attributes, clippy::allow_attributes_without_reason)] (#17335) 2025-01-14 21:37:41 +00:00
mod.rs Generic system config (#17962) 2025-03-12 00:12:30 +00:00
observer_system.rs BevyError: Bevy's new catch-all error type (#18144) 2025-03-07 01:50:07 +00:00
query.rs implement get_many_unique (#18315) 2025-03-16 21:12:26 +00:00
schedule_system.rs BevyError: Bevy's new catch-all error type (#18144) 2025-03-07 01:50:07 +00:00
system_name.rs Remove Implicit std Prelude from no_std Crates (#17086) 2025-01-03 01:58:43 +00:00
system_param.rs Create new NonSendMarker (#18301) 2025-03-23 21:37:40 +00:00
system_registry.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
system.rs Generic system config (#17962) 2025-03-12 00:12:30 +00:00