-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ergonomic tools for working with Commands
from &mut World
#3096
Comments
Quick callout that Commands requires an |
Hmm, right 🤔 I'm running into this with my naive impl. |
Another note: this used to be possible in bevy 0.4, thanks to entity reservation being behind a mutex. |
Actually not quite. Entity reservation is thread safe due to how it uses atomics (both in 0.4 and now), but it was never behind a mutex. We just shared bevy/crates/bevy_ecs/src/core/entities.rs Line 322 in 3b2c6ce
|
The current implementation plays by the rules, but also makes it impossible to do what we did in 0.4. |
Playing with a draft of this, there are two serious problems that must be overcome.
When We could get around the second, less serious issue by forcing users to create a new |
#3946 makes significant progress towards this; see the included example. |
Closed in favor of #6184. |
What problem does this solve or what need does it fill?
Even when working with exclusive world access, work often needs to be deferred to satisfy soundness.
This occurs most commonly when iterating over a query or in other looping contexts.
What solution would you like?
Add
World::commands()
, which fetches a fresh instance ofCommands
.Add
World::apply_commands()
, for a simpleWhat alternative(s) have you considered?
This is a partial, tightly-scoped alternative to some of the frustrations that inspired bevyengine/rfcs#42.
Additional context
World::apply_commands
can currently be achieved with this snippet:The text was updated successfully, but these errors were encountered: