Daily Unreal Column #60 - Tasks Systems
New system for running your code in parallel outside of the game thread.
Together with Unreal Engine 5.0 release, Epic has also released a brand new Tasks Systems. It is a relatively simple way of running code outside of a game thread. On top of that, it also allows user to define a prerequisites for a task, building task chains, and more.
Launching a task is as simple as calling the following.
TTask<int32> Task = UE::Task::Launch(UE_SOURCE_LOCATION, []{ return 42; });
int32 Result = Task.GetResult();
Note that calling Task.GetResult()
will cause the game thread (or any other thread that was responsible for instigating this task) will be stalled until the task is finished.
There is much more to the Tasks Systems, so if this is a topic you would like to know more about I’d recommend reading official documentation here as it’s actually pretty good.