Best Tool For Multithreading Multiple Tasks

Ok, so I guess this is something no one can help me with?

I did some more googling and reading to see if there was anything out there at all I could use. Figured I’d update this in case anyone else wants to follow along the struggle to use this fairly basic multi-threading functionality in Unreal.

This article (unreal_source_explained/thread.md at master · donaldwuid/unreal_source_explained · GitHub) on a seemingly semi-defunct github project was very useful in at least understanding how these systems are meant to fit together. As was this one (https://zhuanlan.zhihu.com/p/62310930) which was more helpful then a lot of things I saw even though it was auto-translated by Google from Chinese. Feels like I shouldn’t need to go to these lengths but I guess that’s the state of things.

What I’ve gathered so far is that FQueuedThreadPool would be what I would want. This thread pool implementation is built on top of FRunnable/FRunnableThread, which compile out to the native system’s thread implementation. One article (in Chinese) even mentioned “UE4 has also done a lot of work on the performance optimization of thread pools.” Would be great if developers could easily access that performance. Oh well.

Seems the way to do that is create a FQueuedThreadPoolBase object and make use the ‘Create(uint32 InNumQueuedThreads, uint32 StackSize, EThreadPriority ThreadPriority, const TCHAR* Name)’ and ‘AddQueuedWork(IQueuedWork* InQueuedWork, EQueuedWorkPriority InQueuedWorkPriority)’ functions. Still looking for any example of implementing the IQueuedWork interface. Also would be great to see these actually return data, as I’ll need that eventually. Looks like I might have to trial and error my completely through that on my own.

As for the Task System, in still remains unclear whether it can be run over multiple frames. Still might need to look into this.

3 Likes