Replies: 1 comment 1 reply
-
If I remember correctly Stride MicroThreads are usually just managed async await in C#. If you want full multithreading the Dispatcher class has been very helpful for me and has been a ton faster than the built in C# Parallel class. With this being said thread safety for async scripts should be fine as far as I understand it. @Eideren might be a better person to give their 2 cents here since they have helped me a ton with multithreading Stride in Discord before. I made a video about the Dispatcher which also shows how you can have thread safe data using Concurrent arrays I used that with a mix of ECS by using the built in EntityProcessor features of Stride briefly explained simply by me here |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm new to Stride. I'm prototyping a game that will require a lot of simulation logic, and I'd like to take advantage of multi-core compute as much as possible.
I poked around in source a bit to look at the async script implementation and I was wondering the following:
It looks like the async scripts are ran into to their own "Microthread". I took a look at the code, interesting stuff. When I start an async script does it start on a real different cpu bound thread different from the main game loop? Or does it start on the main game loop, with async continuations continuing onto the game loop? I'm assuming its the latter. Also, are engine members thread-safe? If I work with an entity from a different thread, add components, work with properties, is that thread-safe? I'm assuming its not.
I'm assuming that async scripts work a lot like async/await in desktop applications. Where the continuations are dispatch back to the "main thread", and only CPU bound tasks are actually multithreaded, I/O, timer bounded operations are true async single threaded.
If my assumptions are correct, I intend on making async scripts that await on large cpu-bound tasks, which spit out a large model of data, which I then assign to my game objects in the contination, sort of like this:
Thank you! By the way, as a software developer, I love Stride. The architecture is awesome.
Beta Was this translation helpful? Give feedback.
All reactions