bevyengine / bevyengine/bevy

🐢 Create feature flag for `!Send` `World`

Open
#17,697 1 comment 0 reactions 0 assignees View on GitHub
A-ECS C-Feature
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

This is a sub-issue of #17667. See that issue for more high-level details.

Make sure #17682 is completed before working on this issue.

## What problem does this solve or what need does it fill?

`World` is currently `Send`, but cannot be dropped in a different thread than it was created in due to `!Send` resources that it owns. If dropped in the wrong thread, the program will panic. This is not desired behavior.

## What solution would you like?

Add a feature flag that will toggle between these 2 states:
1. All of `World` and it's components (and resources) are `Send`
2. All of `World` and it's components (and resources) are `!Send`

That way `World` is always either completely `Send` or completely `!Send`, instead of it's current mixed state, and flipping between them is controlled with a feature flag.

## Additional context

This solution requires that all `World`s in a single binary are either `Send` or `!Send`. There is a future issue created for allowing both `Send` and `!Send` `World`s to exist in the same binary, but that is for a later step. This solution is an intermediate solution and a part of the larger scope of #17667. What this issue hopes to accomplish is to do the following:

1. Make behavior of `World` more expected by allowing `Send` `World` to be dropped in any thread without panicking
2. Allow the option for binaries to use purely `!Send` `World`s, which is currently desired by developers of web-based apps and some niche targets like Gameboy.
3. Setup bevy `World`s to distinctly choose between `Send` and `!Send` so the future transition to inclusively support `Send` and `!Send` `World`s in the same binary is smoother

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.