🐢 Eliminate !Send
resources by supporting Send
and !Send
World
in the same binary
#17667
Labels
C-Feature
A new feature, making something new possible
S-Needs-Triage
This issue needs to be labelled
What problem does this solve or what need does it fill?
This issue is a replacement and extension of #17517, which attempts to solve the same problem by creating an optionally
!Send
World
using generics. The problems with!Send
resources listed in that issue are the same issues we are trying to solve here:Through discussion on Discord and experimentation, we have determined that making
World
optionally!Send
using generics is a bit messy and hacky, and we want a more long-term solution rather than a work-around.In summary, we need to solve these problems:
!Send
resources so the resources-as-components effort can be unblocked, and...!Send
resources while still supporting their!Send
statusWhat solution would you like?
Short term, we can replace
!Send
resources withthread_local!
. This will unblock the resources-as-components effort. However,thread_local!
requiresstd
, which conflicts with Bevy's support forno_std
, so this is not a good long-term solution.Long term, @bushrat011899 brought up supporting both
Send
and!Send
World
s in the same binary. This would allow us to store the data that is currently in!Send
resources in it's own!Send
World
as!Send
components (since resources-as-components aims to remove the concept of resources altogether). If data needs to be shared from theSend
World
to the!Send
World
, @maniwani has suggested an API feature for sending functions to be run on other worlds. Usage might look something like this:The long-term plan looks like this:
thread_local!
so that resources-as-components is unblocked 🐢 Make!Send
resourcesthread_local!
#17682World
and all of it's components into!Send
, which will help on platforms that don't support multi-threadingSend
and!Send
World
in a single binarythread_local!
global vars into a new!Send
World
as!Send
componentsMore issues will be created to break this work out further
What alternative(s) have you considered?
Some ideas we have discussed:
Send
World
(not supporting!Send
World
) and requiring that users store their own!Send
data. However, that would come at the cost of worse UXSend
World
or a!Send
World
in the same binary, but not both simultaneously and using a separate data store for!Send
global data to replace our!Send
resource usage. However, this would require the creation of a new!Send
data store, which can be solved automatically by just creating support forSend
and!Send
World
s to co-exist. Imo, it is cleaner to use a!Send
World
as a!Send
data store and doesn't require us to re-engineer something we already have implemented. Plus having aSend
and!Send
World
co-exist in the same binary is more dynamically useful (it's more general and has potential to be more generally useful to end users and/or other bevy teams to solve a variety of other problems).Why 🐢 turtle emoji?
Because that's the name of the Discord work group that discusses this issue. And turtles are cute.
The text was updated successfully, but these errors were encountered: