Skip to content

Adding change_tick to deferred_world#22941

Open
andristarr wants to merge 3 commits intobevyengine:mainfrom
andristarr:22788.exposing-change_tick-deferred_world
Open

Adding change_tick to deferred_world#22941
andristarr wants to merge 3 commits intobevyengine:mainfrom
andristarr:22788.exposing-change_tick-deferred_world

Conversation

@andristarr
Copy link
Contributor

Objective

Fixes #22788

Solution

  • Adding change_tick to deferred_world

Testing

  • Passes

Showcase

  • You can access change_tick to get Tick from deferred_world

Copy link
Contributor

@andriyDev andriyDev left a comment

Choose a reason for hiding this comment

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

Thanks!!

@andriyDev andriyDev added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. labels Feb 13, 2026
pub fn change_tick(self) -> Tick {
// SAFETY:
// - we only access world metadata, no structural changes happening
unsafe { self.world.world_metadata().read_change_tick() }
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, sorry, I specifically want to avoid using read_change_tick(). We should be able to access the change tick directly without any synchronization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! :)

@andriyDev andriyDev 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 Feb 13, 2026

/// Gets the current change tick of [`DeferredWorld`].
#[inline]
pub fn change_tick(self) -> Tick {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't going to be very useful if it consumes self completely :) You almost certainly want &self in the function argument here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow good catch! Although, I think this should be &mut self, to match World. Since this is an AtomicU32, someone might come along and mutate this under our feet. World makes this ok since you have exclusive access to the AtomicU32, and DeferredWorld should have the same kind of access.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

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-Refinement Improves output quality, without fixing a clear bug or adding new functionality. D-Trivial Nice and easy! A great choice to get started with Bevy S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeferredWorld is missing World::change_tick method.

3 participants