Skip to content
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

Add a method to run read-only systems using &World #8849

Merged
merged 4 commits into from Jun 15, 2023

Conversation

JoJoJet
Copy link
Member

@JoJoJet JoJoJet commented Jun 15, 2023

Objective

Resolves #7558.

Systems that are known to never modify the world implement the trait ReadOnlySystem. This is a perfect place to add a safe API for running a system with a shared reference to a World.


Changelog

  • Added the trait method ReadOnlySystem::run_readonly, which allows a system to be run using &World.

@JoJoJet JoJoJet added C-Enhancement A new feature A-ECS Entities, components, systems, and events labels Jun 15, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this missing a blanket impl for ReadOnlySystem for functions that take &World?

Ideally this would also be implemented for all systems where all of the parameters are read-only as well, but until we can actually make queries via &World this isn't going to be super useful either way.

@JoJoJet
Copy link
Member Author

JoJoJet commented Jun 15, 2023

This trait is implemented for any function system whose parameters all implement ReadOnlySystemParam, which includes &World. This PR just adds an extension method to all the types that already implement ReadOnlySystem.

@alice-i-cecile
Copy link
Member

Oh I see! The trait already existed. Fantastic, thank you :)

@james7132 james7132 added this pull request to the merge queue Jun 15, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jun 15, 2023
Merged via the queue into bevyengine:main with commit 8ec8149 Jun 15, 2023
24 checks passed
@JoJoJet JoJoJet deleted the system-run-read-only branch June 16, 2023 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Enhancement A new feature S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Read-only system::run_read_only
3 participants