50 so... I would like to simplify how multi threading in my game is done. Specifically, the way that characters get updated.
Right now characters have both an update function and an update_par function. The update_par function is used to update the character in ways that multiple characters can do at the same time. For example calculating the path to their destination. the update function is used for everything else for example actually walking said path. The main reason I want to get rid of how its currently done is because I now need to iterate 2 times over the character list and though one of those iterations can use multiple threads that won't always be the case (WASM being one of those cases)
The problem that I run into is that I can't think of a nice way to fix it. Either I change it so that on WASM I only use 1 loop to run both but I feel that the difference between native and WASM becomes too big.
The other thing that I could do is to combine the update and update_par functions. However, this means that I need to provide certain values using Arc<Mutex<T>> however this will mean that the moment one of those threads needs access to one of those values all the other threads need to wait on this thread before they can also do this. This, at least in my eyes kind of defeats the point of using multiple threads.....
There is also something else that I can do, but that will only make native builds use the multi threading better while also slowing down the WASM builds. Or in other words, it fixes the problem for the one case where the problem doesn't have to be fixed while making the case when it needs to be fixed worse.