ue-async-threading
Use when offloading work off the game thread, dispatching results back to it, running data-parallel loops, or scheduling timers and tickers in UE C++. Also use when the user mentions 'UE::Tasks::Launch', 'FPipe', 'FTaskEvent', 'AsyncTask', 'Async()', 'TFuture', 'TPromise', 'ParallelFor', 'FRunnable', 'FAsyncTask', 'FCriticalSection', 'FRWLock', 'UE::FMutex', 'TMpscQueue', 'IsInGameThread', 'FTSTicker', 'SetTimer', 'thread safety'. For async asset loading, see ue-data-assets-tables; for smart pointers and GC lifetime, see ue-cpp-foundations.
quodsoler · Static checks on file
Installation
Read the source and dependencies before running a command. Copying does not install or execute anything.
npx skills add quodsoler/unreal-engine-skills --skill ue-async-threadingAbout this skill
name: ue-async-threading description: "Use when offloading work off the game thread, dispatching results back to it, running data-parallel loops, or scheduling timers and tickers in UE C++. Also use when the user mentions 'UE::Tasks::Launch', 'FPipe', 'FTaskEvent', 'AsyncTask', 'Async()', 'TFuture', 'TPromise', 'ParallelFor', 'FRunnable', 'FAsyncTask', 'FCriticalSection', 'FRWLock', 'UE::FMutex', 'TMpscQueue', 'IsInGameThread', 'FTSTicker', 'SetTimer', 'thread safety'. For async asset loading, see ue-data-assets-tables; for smart pointers and GC lifetime, see ue-cpp-foundations." metadata: version: "2.0.0" engine: "5.8"
UE Async and Threading
Target engine: UE 5.8. APIs below are verified against the 5.8 headers; older forms are listed under "Deprecated — do not use".
This skill covers moving work off the game thread and bringing results back: the UE::Tasks system (Tasks/Task.h, Tasks/Pipe.h), Async/TFuture (Async/Async.h, Async/Future.h), thread-pool FAsyncTask (Async/AsyncWork.h), ParallelFor, dedicated FRunnable threads, locks and lock-free queues, FTSTicker and FTimerManager. Everything except timers is in the Core module; FTimerManager is in Engine; ENQUEUE_RENDER_COMMAND is in RenderCore. Build.cs: PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine" }); and add "RenderCore" only when enqueuing render commands.
Context
Read .agents/ue-project-context.md if it exists (module names, conventions, enabled plugins, GAS/networking setup). Do not stop if it is missing.
Identify the area from the request and the codebase. Ask only when two plausible readings would produce different code.
| Request is about… | Go to |
|---|---|
| Which API fits | Pattern Selection |
| One-shot background work, chaining, prerequisites, events | UE::Tasks |
| Serializing access to a resource without a dedicated thread | FPipe and FTaskConcurrencyLimiter |
| Futures, promises, dispatch to the game thread | Async, TFuture and AsyncTask |
| Reusable pooled work unit | FAsyncTask and FAutoDeleteAsyncTask |
| Data-parallel loops | ParallelFor |
| Long-lived dedicated thread | FRunnable and FRunnableThread |
| Locks, events, atomics, queues, shared pointers | Synchronization |
| Per-frame callbacks and delayed calls | Tickers and Timers |
| UObject, GC and render-thread rules | Thread Safety Rules |
| Old forms | Deprecated — do not use |
Threading Model
| Thread | Check | Owns |
|---|---|---|
| Game thread | IsInGameThread() (CoreGlobals.h) | All UObject access, Blueprint, gameplay, timers, tickers |
| Render thread | IsInRenderingThread() | Scene proxies, render commands (ENQUEUE_RENDER_COMMAND) |
| RHI thread | IsInRHIThread() | GPU command submission |
| Worker threads | none | UE::Tasks scheduler, TaskGraph AnyThread, ParallelFor |
| Thread pools | none | GThreadPool, GBackgroundPriorityThreadPool, GIOThreadPool; GLargeThreadPool only WITH_EDITOR (Misc/QueuedThreadPool.h) |
Golden rule: UObjects are game-thread-only. Compute off-thread on plain data, then apply results on the game thread through a TWeakObjectPtr (see Thread Safety Rules).
Pattern Selection
| Need | Use | Result |
|---|---|---|
| One-shot background work, dependencies, chaining | UE::Tasks::Launch | TTask<T> |
| Run a lambda on the game thread from anywhere | AsyncTask(ENamedThreads::GameThread, ...) | none |
| Future-style result with execution-context choice | Async(EAsyncExecution, ...) | TFuture<T> |
| Serialize tasks touching one resource (FIFO) | UE::Tasks::FPipe | TTask<T> |
| Cap how many tasks run at once | UE::Tasks::FTaskConcurrencyLimiter | none |
| Reusable pooled work unit with owner-managed lifetime | FAsyncTask<T> / FAutoDeleteAsyncTask<T> | via GetTask() |
| Data-parallel loop, caller blocks | ParallelFor | none |
| Long-lived thread (socket, file watcher, sim loop) | FRunnable + FRunnableThread::Create | manual |
| Per-frame callback outside an Actor tick | FTSTicker::GetCoreTicker().AddTicker | handle |
| Delayed or repeating call on the game thread | FTimerManager::SetTimer | FTimerHandle |
UE::Tasks
#include "Tasks/Task.h"
// Tasks/Task.h:299
template<typename TaskBodyType>
UE::Tasks::TTask<TInvokeResult_T<TaskBodyType>> Launch(const TCHAR* DebugName, TaskBodyType&& TaskBody,
ETaskPriority Priority = ETaskPriority::Normal,
EExtendedTaskPriority ExtendedPriority = EExtendedTaskPriority::None,
ETaskFlags Flags = ETaskFlags::None);
// Tasks/Task.h:324 — same, with a prerequisites collection as the third parameter
template<typename TaskBodyType, typename PrerequisitesCollectionType>
UE::Tasks::TTask<TInvokeResult_T<TaskBodyType>> Launch(const TCHAR* DebugName, TaskBodyType&& TaskBody,
PrerequisitesCollectionType&& Prerequisites,
ETaskPriority Priority = ETaskPriority::Normal,
EExtendedTaskPriority ExtendedPriority = EExtendedTaskPriority::None,
ETaskFlags Flags = ETaskFlags::None);
using namespace UE::Tasks;
TArray<int32> Data;
TTask<int32> Sum = Launch(UE_SOURCE_LOCATION, [Data]() { return ComputeSum(Data); });
// Prerequisites: TaskB runs after TaskA completes. Handles are copyable; GetResult() is non-const.
TTask<FVector> TaskA = Launch(UE_SOURCE_LOCATION, []() { return FVector(1.f, 2.f, 3.f); });
TTask<void> TaskB = Launch(UE_SOURCE_LOCATION,
[TaskA]() mutable { const FVector Pos = TaskA.GetResult(); ConsumePosition(Pos); },
Prerequisites(TaskA), ETaskPriority::BackgroundNormal);
// Manual gate: nothing after the event starts until Trigger()
FTaskEvent Gate{ UE_SOURCE_LOCATION };
TTa
Read the complete source ↗