Does calling an object method in the Run method of FRunnable happen in its own thread that runs the said FRunnable instead of running in the game thread? The method itself is thread-safe, being const & just doing some heavy weight calculations, but it needs to be a method, instead of static, otherwise too much data has to be copied onto the thread. I tried running Sleep inside it & it didn’t halt the game thread, but it did halt the worker, so I assume it works correctly, but I’ll ask just to be sure none the less.
It will run on thread which executes Run, which is thread that FRunnable is running
C++ by it self by pure syntax is not support multi-threading, the functions that generate instructions for CPU to create and switch threads or call function in OS that does that is one what makes multi-threading work in C++, but it’s not really C++ feature. C++ compiler compiles functions to machine code as they are without even thinking about threading, the called function would need to switch thread on there own to do so, and which as much as i seen ton gameplay code in engine i never seen it using multithreading (well maybe except tick system?).
So your call in Run will simply make current thread jump to function you called, it will does that because CPU instructions generated by compiler will order it to do so.
Thanks, the last time I used threading was in college… in Java… 5 years ago… I need it because I’m implementing an A* path-finding for flying pawns. With enough nodes & pawns A* can get really heavy. Everything seems to work like a clock for now & the performance is top-notch because I’m using highly optimized heuristics, but even now for a small room it takes around a 1k iterations (I count the amount of times the neighbors have to be iterated, it’s of course much less for the upper loop) to get to the goal for a single pawn & that’s for like a 25^3 amount of nodes. A* is a beast. That’s with my best heuristic that shouldn’t work well for maze-like levels. I offer multiple ones that should work well in different situations.