🐢 Create inter-thread executor API #18172
Labels
A-ECS
Entities, components, systems, and events
A-Tasks
Tools for parallel and async work
C-Feature
A new feature, making something new possible
D-Complex
Quite challenging from either a design or technical perspective. Ask for help!
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
This is a sub-issue of #17667. See that issue for more high-level details.
Borrows ideas from maniwani's PR to remove
!Send
resourcesWhat problem does this solve or what need does it fill?
In order to finish removing
!Send
resources (started here), we need a way of forcing certain tasks to run on main thread, without depending onNonSendRes
system params.What solution would you like?
Overall plan
We will spawn a new thread which holds an event loop proxy and holds a sender and receiver for winit.
World
will hold another send/recv for the proxy. A system param will be created for use in systems and will come with a method that takes a callback function and executes the function on the main thread. It does so by communicating with the proxy, which wakes the event loop and sends the callback to the event loop, which will then block until execution is finished.Details
@maniwani provided the following process:
and provided this rough example:
NOTE: the example includes separating the world from the winit thread, but that is out of the scope of this issue and will be completed as work for a future issue. The scope of this issue is only to create this functionality, along with a few tests, but not to apply it anywhere (other than the tests).
This would allow code that needs to be run on main thread to stay on main thread without depending on
NonSendRes
.What alternative(s) have you considered?
We have talked about sending entire Systems to be executed on different threads, but this would prevent
The text was updated successfully, but these errors were encountered: