Skip to content

Rename Add to Queue for methods with deferred semantics #15234

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

Merged
merged 12 commits into from
Sep 17, 2024

Conversation

BenjaminBrienen
Copy link
Contributor

@BenjaminBrienen BenjaminBrienen commented Sep 15, 2024

Objective

Solution

  • Trivial refactor to rename the method. The duplicate method push was removed as well. This will simpify the API and make the semantics more clear. Add implies that the action happens immediately, whereas in reality, the command is queued to be run eventually.
  • ChildBuilder::add_command has similarly been renamed to queue_command.

Testing

Unit tests should suffice for this simple refactor.


Migration Guide

  • Commands::add and Commands::push have been replaced with Commnads::queue.
  • ChildBuilder::add_command has been renamed to ChildBuilder::queue_command.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Sep 15, 2024
@alice-i-cecile
Copy link
Member

@BenjaminBrienen
Copy link
Contributor Author

Can you replace https://docs.rs/bevy/latest/bevy/hierarchy/struct.ChildBuilder.html#method.add_command as part of this PR?

I've already renamed it to enqueue_command. I guess I should mention that in the description as well! Let me know if I've misunderstood you and indeed forgot a refactor.

@alice-i-cecile
Copy link
Member

Aha, I missed it! I've updated the migration guide in your PR.

@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Sep 15, 2024
Copy link
Contributor

@NthTensor NthTensor left a comment

Choose a reason for hiding this comment

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

Surprised this isn't a larger change. I like this much better.

Do we want to do the same with EntityCommands?

@NthTensor NthTensor added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 15, 2024
@alice-i-cecile
Copy link
Member

Do we want to do the same with EntityCommands?

Yes please!

@BenjaminBrienen
Copy link
Contributor Author

BenjaminBrienen commented Sep 15, 2024

So instead of insert_reflect we have enqueue_reflect? All the ones that wrap around commands.enqueue, I assume.
If so, then we'd also be renaming InsertReflectWithRegistry.

Copy link
Member

@janhohenheim janhohenheim left a comment

Choose a reason for hiding this comment

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

Happy to see this resolved so quickly, thanks :)

@NiseVoid
Copy link
Contributor

So instead of insert_reflect we have enqueue_reflect? All the ones that wrap around commands.enqueue, I assume. If so, then we'd also be renaming InsertReflectWithRegistry.

I think @NthTensor was referring to EntityCommands::add

@janhohenheim
Copy link
Member

@BenjaminBrienen yeah, looks like you missed this one. The reflect stuff doesn't need to be touched :)

@alice-i-cecile
Copy link
Member

So instead of insert_reflect we have enqueue_reflect? All the ones that wrap around commands.enqueue, I assume. If so, then we'd also be renaming InsertReflectWithRegistry.

insert_reflect is different: it adds a new component. The APIs we want to change are just those that are adding new commands directly. This semantic similarity between add and insert is a huge part of why we want this change in the first place!

@BenjaminBrienen
Copy link
Contributor Author

@BenjaminBrienen yeah, looks like you missed this one. The reflect stuff doesn't need to be touched :)

Weird. This file seems to escape VSCode's search feature. fn add doesn't show the file for me. Fixing now!

@alice-i-cecile
Copy link
Member

@iiYese
Copy link
Contributor

iiYese commented Sep 15, 2024

Is there something better than enqueue? Cause if you do .enqueue(A) and then .enqueue(B) but A has the side effect of enqueueing C the effect order is A, C, B not A, B, C.

@alice-i-cecile
Copy link
Member

Is there something better than enqueue? Cause if you do .enqueue(A) and then .enqueue(B) but A has the side effect of enqueueing C the effect order is A, C, B not A, B, C.

I like queue better but I'm pretty sure I'm outvoted :p Doesn't solve the problem raised there though. IMO this is a very weird edge case: worth mentioning in the docs but not worth using a less clear name.

@Shatur
Copy link
Contributor

Shatur commented Sep 15, 2024

I personally liked "push" 😅
But I also prefer "queue" to "enqueue".

@janhohenheim
Copy link
Member

Big queue fan here, but also not a native speaker

@alice-i-cecile
Copy link
Member

@BenjaminBrienen can you please swap all uses of enqueue to queue? I've heard enough!

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Sep 15, 2024
@BenjaminBrienen
Copy link
Contributor Author

BenjaminBrienen commented Sep 15, 2024

@BenjaminBrienen can you please swap all uses of enqueue to queue? I've heard enough!

Should I leave this "enqueue" alone?
https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/renderer/mod.rs#L152

There are a few more examples of "enqueue" in doc comments.

@alice-i-cecile
Copy link
Member

Yep, leave the rendering stuff alone for this PR. I'm also fine to leave the docs alone.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 15, 2024
@alice-i-cecile
Copy link
Member

Awesome. If you have a chance, please update the PR title and description to match. Otherwise I'll do it on merging tomorrow during my weekly merge train.

@BenjaminBrienen BenjaminBrienen changed the title Rename Add to Enqueue Rename Add to Queue for methods with deferred semantics Sep 15, 2024
@alice-i-cecile
Copy link
Member

@BenjaminBrienen doc links are broken due to the rename (scroll down the CI run...) and there's a simple merge conflict. Ping me when you've gotten to that and I'll merge it in.

@BenjaminBrienen
Copy link
Contributor Author

@alice-i-cecile should be fixed now, just waiting on the CI :)

@BenjaminBrienen
Copy link
Contributor Author

now it should be good... ?

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 17, 2024
Merged via the queue into bevyengine:main with commit b45d83e Sep 17, 2024
26 checks passed
@BenjaminBrienen BenjaminBrienen deleted the rename-add-to-enqueue branch September 17, 2024 08:01
@BenjaminBrienen BenjaminBrienen self-assigned this Nov 10, 2024
@BenjaminBrienen BenjaminBrienen removed 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 Nov 10, 2024
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-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename EntityCommands::add to EntityCommands::queue
8 participants