Add App::setup_non_send, deprecate insert_non_send#25067
Open
Supremesv715 wants to merge 1 commit into
Open
Conversation
eswartz
approved these changes
Jul 20, 2026
|
|
||
| /// Queues a `Send` closure that inserts [`!Send`](Send) data into the app's [`World`]. | ||
| /// | ||
| /// Unlike [`insert_non_send`](Self::insert_non_send), `func` is not run immediately. |
Contributor
There was a problem hiding this comment.
A nit: it seems like the primary explanation comment shouldn't justify itself against a deprecated method, but instead just make its own case as the following sentences mostly do. (Not to mention there's no "func" to "run immediately" in insert_non_send anyway :)
IMHO the PR description and migration guide explain why this method exists; once the deprecated methods are removed, the comments submitted here should stand alone without editing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
App::insert_non_sendconstructs!Sendvalues immediately at the app-building call site, which can put them on the wrong thread relative to the runner (e.g.WinitPlugin).!Senddata is created on the thread that actually runs the app.Solution
App::setup_non_send, which queues aSendclosure and runs it once at the start ofApp::runon the calling thread.App::insert_non_send(and update theinsert_non_send_resourcenote) in favor ofsetup_non_send.examples/app/log_layers_ecs.rsand add a migration guide.App::init_non_sendis unchanged.Testing
cargo test -p bevy_app setup_non_sendcargo run --example log_layers_ecs