-
-
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
[Merged by Bors] - Remove Sync
bound from Local
#5483
Conversation
add `Sync` bound back to `Resource`
bors try |
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 like this a lot. Even though the use-case seems niche, it'll feel really good for that niche user when they realize it just works.
Co-authored-by: JoJoJet <[email protected]>
I like the relaxation on the bounds for Locals, but I'm unsure about taking on |
The idea is to just swap |
users could also depend on it. see the issue on |
In that case, we can typedef |
btw, i don't need it anymore as #5819 is now merged. also, if in the case that users would need it, i would prefer just removing it outright as bevy's api isn't really stabilized yet. I think bevy's development is fast enough to update |
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.
One note about a followup to this PR, otherwise LGTM.
bors r+ |
# Objective Currently, `Local` has a `Sync` bound. Theoretically this is unnecessary as a local can only ever be accessed from its own system, ensuring exclusive access on one thread. This PR removes this restriction. ## Solution - By removing the `Resource` bound from `Local` and adding the new `SyncCell` threading primative, `Local` can have the `Sync` bound removed. ## Changelog ### Added - Added `SyncCell` to `bevy_utils` ### Changed - Removed `Resource` bound from `Local` - `Local` is now wrapped in a `SyncCell` ## Migration Guide - Any code relying on `Local<T>` having `T: Resource` may have to be changed, but this is unlikely. Co-authored-by: PROMETHIA-27 <[email protected]>
Pull request successfully merged into main. Build succeeded: |
Sync
bound from Local
Sync
bound from Local
# Objective Currently, `Local` has a `Sync` bound. Theoretically this is unnecessary as a local can only ever be accessed from its own system, ensuring exclusive access on one thread. This PR removes this restriction. ## Solution - By removing the `Resource` bound from `Local` and adding the new `SyncCell` threading primative, `Local` can have the `Sync` bound removed. ## Changelog ### Added - Added `SyncCell` to `bevy_utils` ### Changed - Removed `Resource` bound from `Local` - `Local` is now wrapped in a `SyncCell` ## Migration Guide - Any code relying on `Local<T>` having `T: Resource` may have to be changed, but this is unlikely. Co-authored-by: PROMETHIA-27 <[email protected]>
# Objective Currently, `Local` has a `Sync` bound. Theoretically this is unnecessary as a local can only ever be accessed from its own system, ensuring exclusive access on one thread. This PR removes this restriction. ## Solution - By removing the `Resource` bound from `Local` and adding the new `SyncCell` threading primative, `Local` can have the `Sync` bound removed. ## Changelog ### Added - Added `SyncCell` to `bevy_utils` ### Changed - Removed `Resource` bound from `Local` - `Local` is now wrapped in a `SyncCell` ## Migration Guide - Any code relying on `Local<T>` having `T: Resource` may have to be changed, but this is unlikely. Co-authored-by: PROMETHIA-27 <[email protected]>
# Objective Currently, `Local` has a `Sync` bound. Theoretically this is unnecessary as a local can only ever be accessed from its own system, ensuring exclusive access on one thread. This PR removes this restriction. ## Solution - By removing the `Resource` bound from `Local` and adding the new `SyncCell` threading primative, `Local` can have the `Sync` bound removed. ## Changelog ### Added - Added `SyncCell` to `bevy_utils` ### Changed - Removed `Resource` bound from `Local` - `Local` is now wrapped in a `SyncCell` ## Migration Guide - Any code relying on `Local<T>` having `T: Resource` may have to be changed, but this is unlikely. Co-authored-by: PROMETHIA-27 <[email protected]>
…7718) # Objective The type `SyncCell<T>` (added in #5483) is used to force any wrapped type to be `Sync`, by only allowing exclusive access to the wrapped value. This restriction is unnecessary for types which are already `Sync`. --- ## Changelog + Added the method `read` to `SyncCell`, which allows shared access to values that already implement the `Sync` trait.
…evyengine#7718) # Objective The type `SyncCell<T>` (added in bevyengine#5483) is used to force any wrapped type to be `Sync`, by only allowing exclusive access to the wrapped value. This restriction is unnecessary for types which are already `Sync`. --- ## Changelog + Added the method `read` to `SyncCell`, which allows shared access to values that already implement the `Sync` trait.
# Objective bevyengine#5483 allows for the creation of non-`Sync` locals. However, it's not actually possible to use these types as there is a `Sync` bound on the `Deref` impls. ## Solution Remove the unnecessary bounds.
Objective
Currently,
Local
has aSync
bound. Theoretically this is unnecessary as a local can only ever be accessed from its own system, ensuring exclusive access on one thread. This PR removes this restriction.Solution
Resource
bound fromLocal
and adding the newSyncCell
threading primative,Local
can have theSync
bound removed.Changelog
Added
SyncCell
tobevy_utils
Changed
Resource
bound fromLocal
Local
is now wrapped in aSyncCell
Migration Guide
Local<T>
havingT: Resource
may have to be changed, but this is unlikely.