Skip to content

Component: Sync (might be) too strict. #2487

Closed as not planned
Closed as not planned
@DJMcNab

Description

@DJMcNab

What problem does this solve or what need does it fill?

Our requirements are too strict. This stops us from using types which are Send but not Sync in components, such as Cell<T>.

What solution would you like?

Remove the bound of Sync on component, and audit all the methods of World to ensure that any which go from &World->&T require T: Sync (primarily the SystemParam impl for &'_ T).

Note that the impl for &'_ mut T would not require Sync, since we guarantee that this reference is only on one thread (since the resultant Mut<T> can be used to get an &mut T directly).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-Code-QualityA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile timesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions