-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 by Bors] - Unique WorldId #2827
Conversation
crates/bevy_ecs/src/world/mod.rs
Outdated
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |val| { | ||
val.checked_add(1) | ||
}) | ||
.expect("More bevy `World`s have been created than is supported. Please tell us what you were doing, because frankly I'm impressed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I'd removed this second sentence before committing. I'm happy to keep it as-is though 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the error message is cleaned up this LGTM.
I don't have strong feelings about u32 vs u64 for world ids. u32
is probably slightly more reasonable as there's effectively no way to break those limits without going OOM elsewhere. But on the other hand, there's no real cost to storing more data here 🤔
@@ -407,7 +406,7 @@ impl Default for RunOnce { | |||
fn default() -> Self { | |||
Self { | |||
ran: false, | |||
system_id: SystemId::new(), | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary whitespace, I'm surprised rustfmt doesn't check for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Regarding As @alice-i-cecile said, it is unlikely to break the limit of Whereas portability and platform support is an actual problem with actual consequences. Let's not needlessly limit the kinds of devices that bevy can run on. |
Hmm, I hadn't considered that - I wonder if there should be a clippy lint for that (beyond just using the more general disallowed function) We should use |
I dig these changes. I do think that ultimately we might need a unique SystemId for "manually triggered systems" and "reactions", but I'm happy to just re-add that if/when its actually needed. SystemId has been dead code since bevy_ecs's inception. Removing it makes sense. |
bors r+ |
Lol I have a nasty habit of not checking CI before bors-ing. You should just swap out the |
# Objective Fixes these issues: - `WorldId`s currently aren't necessarily unique - I want to guarantee that they're unique to safeguard my librarified version of #2805 - There probably hasn't been a collision yet, but they could technically collide - `SystemId` isn't used for anything - It's no longer used now that `Locals` are stored within the `System`. - `bevy_ecs` depends on rand ## Solution - Instead of randomly generating `WorldId`s, just use an incrementing atomic counter, panicing on overflow. - Remove `SystemId` - We do need to allow Locals for exclusive systems at some point, but exclusive systems couldn't access their own `SystemId` anyway. - Now that these don't depend on rand, move it to a dev-dependency ## Todo Determine if `WorldId` should be `u32` based instead
Build failed (retrying...): |
# Objective Fixes these issues: - `WorldId`s currently aren't necessarily unique - I want to guarantee that they're unique to safeguard my librarified version of #2805 - There probably hasn't been a collision yet, but they could technically collide - `SystemId` isn't used for anything - It's no longer used now that `Locals` are stored within the `System`. - `bevy_ecs` depends on rand ## Solution - Instead of randomly generating `WorldId`s, just use an incrementing atomic counter, panicing on overflow. - Remove `SystemId` - We do need to allow Locals for exclusive systems at some point, but exclusive systems couldn't access their own `SystemId` anyway. - Now that these don't depend on rand, move it to a dev-dependency ## Todo Determine if `WorldId` should be `u32` based instead
Build failed: |
That's annoying - I even knew that lint would trigger but forgot to deal with it. I explicitly chose not to make it a I still expose the constructor function publicly because it could be used e.g. for tests in external crates, although I'm not certain that's really needed. |
Delete SystemId Also remove `rand` as a normal dependency 🎉 Change WorldId to use usize Add tests and a module for `WorldId`
3f65af8
to
4e84649
Compare
bors r+ |
# Objective Fixes these issues: - `WorldId`s currently aren't necessarily unique - I want to guarantee that they're unique to safeguard my librarified version of #2805 - There probably hasn't been a collision yet, but they could technically collide - `SystemId` isn't used for anything - It's no longer used now that `Locals` are stored within the `System`. - `bevy_ecs` depends on rand ## Solution - Instead of randomly generating `WorldId`s, just use an incrementing atomic counter, panicing on overflow. - Remove `SystemId` - We do need to allow Locals for exclusive systems at some point, but exclusive systems couldn't access their own `SystemId` anyway. - Now that these don't depend on rand, move it to a dev-dependency ## Todo Determine if `WorldId` should be `u32` based instead
Objective
Fixes these issues:
WorldId
s currently aren't necessarily uniqueSystemId
isn't used for anythingLocals
are stored within theSystem
.bevy_ecs
depends on randSolution
WorldId
s, just use an incrementing atomic counter, panicing on overflow.SystemId
SystemId
anyway.Todo
Determine if
WorldId
should beu32
based instead