🐢 Make !Send
resources thread_local!
#17682
Labels
C-Feature
A new feature, making something new possible
S-Needs-Triage
This issue needs to be labelled
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 ofthread_local!
. The benefit of usingthread_local!
in this context is that the!Send
resources we are working with are (at least sometimes)!Sync
. Wrapping a var inthread_local!
ensures safety without requiring the wrapped type to beSync
orSend
.What alternative(s) have you considered?
We have talked about:
static
vars withoutthread_local!
, but that requires the var beSync
.!Send
World
s 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 unblockedThe text was updated successfully, but these errors were encountered: