-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Component: Sync (might be) too strict. #2487
Copy link
Copy link
Closed as not planned
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile timesA change motivated by improving speed, memory usage or compile timesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!
What problem does this solve or what need does it fill?
Our requirements are too strict. This stops us from using types which are
Sendbut notSyncin components, such asCell<T>.What solution would you like?
Remove the bound of
Syncon component, and audit all the methods ofWorldto ensure that any which go from&World->&TrequireT: Sync(primarily theSystemParamimpl for&'_ T).Note that the impl for
&'_ mut Twould not requireSync, since we guarantee that this reference is only on one thread (since the resultantMut<T>can be used to get an&mut Tdirectly).What alternative(s) have you considered?
Keep things as they are - we haven't had a need for this yet, and it seems unlikely that we ever will.
However, philosophically there's no reason to have these bounds, and it strictly increases our usefulness.
Additional context
https://doc.rust-lang.org/nomicon/send-and-sync.html
https://doc.rust-lang.org/std/marker/trait.Sync.html