Skip to content
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

🐢 Make !Send resources thread_local! #17682

Open
joshua-holmes opened this issue Feb 4, 2025 · 0 comments
Open

🐢 Make !Send resources thread_local! #17682

joshua-holmes opened this issue Feb 4, 2025 · 0 comments
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@joshua-holmes
Copy link

This is a sub-issue of #17667. See that issue for more high-level details.

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

We are using !Send resources to store mostly global data, such as handles, winit windows, etc. This blocks the resources-as-components effort, which seeks to eliminate the usage of resources.

What solution would you like?

In order to unblock resources-as-components, we need to remove any !Send components and replace them with the use of thread_local!. The benefit of using thread_local! in this context is that the !Send resources we are working with are (at least sometimes) !Sync. Wrapping a var in thread_local! ensures safety without requiring the wrapped type to be Sync or Send.

What alternative(s) have you considered?

We have talked about:

  • Using static vars without thread_local!, but that requires the var be Sync.
  • Creating !Send Worlds to store this data. This is the long term plan (see parent issue), but right now we just need a short-term solution so resources-as-components is unblocked
@joshua-holmes joshua-holmes added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 4, 2025
@joshua-holmes joshua-holmes changed the title Make !Send resources thread_local! 🐢 Make !Send resources thread_local! Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

1 participant