UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FAsyncLoadingThread Class Referencefinal

#include <AsyncLoadingThread.h>

+ Inheritance diagram for FAsyncLoadingThread:

Public Member Functions

 FAsyncLoadingThread (int32 InThreadIndex)
 
virtual ~FAsyncLoadingThread ()
 
virtual ELoaderType GetLoaderType () const override
 
IAsyncPackageLoaderGetIoStorePackageLoader () const
 
void SetIoStorePackageLoader (IAsyncPackageLoader *InIoStorePackageLoader)
 
virtual bool Init ()
 
virtual uint32 Run ()
 
virtual void Stop ()
 
void StartThread () override
 
bool ShouldAlwaysLoadPackageAsync (const FPackagePath &InPackagePath) override
 
int32 LoadPackage (const FPackagePath &PackagePath, FLoadPackageAsyncOptionalParams OptionalParams) override
 
int32 LoadPackage (const FPackagePath &InPackagePath, FName InCustomName, FLoadPackageAsyncDelegate InCompletionDelegate, EPackageFlags InPackageFlags, int32 InPIEInstanceID, int32 InPackagePriority, const FLinkerInstancingContext *InInstancingContext, uint32 InLoadFlags) override
 
EAsyncPackageState::Type ProcessLoading (bool bUseTimeLimit, bool bUseFullTimeLimit, double TimeLimit) override
 
EAsyncPackageState::Type ProcessLoadingUntilComplete (TFunctionRef< bool()> CompletionPredicate, double TimeLimit) override
 
void FlushLoading (TConstArrayView< int32 > RequestIDs) override
 
void NotifyConstructedDuringAsyncLoading (UObject *Object, bool bSubObject) override
 
void NotifyUnreachableObjects (const TArrayView< FUObjectItem * > &UnreachableObjects) override
 
void FireCompletedCompiledInImport (void *AsyncPacakge, FPackageIndex Import)
 
void NotifyRegistrationEvent (FName PackageName, FName Name, ENotifyRegistrationType NotifyRegistrationType, ENotifyRegistrationPhase NotifyRegistrationPhase, UObject *(*InRegister)(), bool InbDynamic, UObject *FinishedObject) override
 
void NotifyRegistrationComplete () override
 
FORCEINLINE FAsyncPackageGetPackage (FWeakAsyncPackagePtr Ptr)
 
void QueueEvent_CreateLinker (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_FinishLinker (FWeakAsyncPackagePtr WeakPtr, int32 EventSystemPriority=0)
 
void QueueEvent_StartImportPackages (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_SetupImports (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_SetupExports (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_ProcessImportsAndExports (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_ExportsDone (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_ProcessPostloadWait (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
void QueueEvent_StartPostLoad (FAsyncPackage *Pkg, int32 EventSystemPriority=0)
 
FORCEINLINE bool IsMultithreaded () override
 
UE_AUTORTFM_ALWAYS_OPEN bool IsAsyncLoadingPackages () override
 
FORCEINLINE bool IsInAsyncLoadThread () override
 
FORCEINLINE bool IsAsyncLoadingSuspendedInternal () const
 
virtual bool IsAsyncLoadingSuspended () override
 
FORCEINLINE int32 GetAsyncLoadingSuspendedCount ()
 
FORCEINLINE int32 GetNumQueuedPackages () override
 
FORCEINLINE int32 GetNumAsyncPackages () override
 
FORCEINLINE FAsyncPackageFindAsyncPackage (const FName &PackageName)
 
void InsertPackage (FAsyncPackage *Package, bool bReinsert=false, EAsyncPackageInsertMode InsertMode=EAsyncPackageInsertMode::InsertBeforeMatchingPriorities)
 
FORCEINLINE FAsyncPackageFindLoadedPackage (const FName &PackageName)
 
void QueuePackage (FAsyncPackageDesc &Package)
 
void CancelLoading () override
 
void ShutdownLoading () override
 
void SuspendLoading () override
 
void ResumeLoading () override
 
FORCEINLINE FAsyncPackageGetPackage (int32 PackageIndex)
 
EAsyncPackageState::Type ProcessAsyncLoading (int32 &OutPackagesProcessed, bool bUseTimeLimit, bool bUseFullTimeLimit, float TimeLimit, FFlushRequest &FlushRequest)
 
void CheckForCycles ()
 
EAsyncPackageState::Type TickAsyncLoading (bool bUseTimeLimit, bool bUseFullTimeLimit, double TimeLimit, FFlushRequest FlushRequest=FFlushRequest())
 
EAsyncPackageState::Type TickAsyncThread (bool bUseTimeLimit, bool bUseFullTimeLimit, double TimeLimit, bool &bDidSomething, FFlushRequest &FlushRequest)
 
void InitializeLoading () override
 
float GetAsyncLoadPercentage (const FName &PackageName) override
 
FEventLoadGraphGetEventGraph ()
 
FPrecacheCallbackHandlerGetPrecacheHandler ()
 
int32 GetThreadIndex () const
 
- Public Member Functions inherited from FRunnable
virtual void Exit ()
 
virtual class FSingleThreadRunnableGetSingleThreadInterface ()
 
virtual ~FRunnable ()
 
- Public Member Functions inherited from IAsyncPackageLoader
virtual ~IAsyncPackageLoader ()
 
virtual void NotifyScriptVersePackage (Verse::VPackage *Package)
 Called for built in packages (currently only VVMIntrinsics.cpp) to allow them to be imported.
 

Static Public Member Functions

static FAsyncLoadingThreadGet ()
 
static void EnterAsyncLoadingTick (int32 ThreadIndex)
 
static void LeaveAsyncLoadingTick (int32 ThreadIndex)
 
static UE_AUTORTFM_ALWAYS_OPEN bool GetIsInAsyncLoadingTick ()
 

Public Attributes

TArray< FAsyncPackage * > AsyncPackagesReadyForTick
 
FAsyncLoadEventQueue EventQueue
 
FThreadSafeCounter RecursionNotAllowed
 

Static Public Attributes

static FAsyncLoadingThreadInstance = nullptr
 

Friends

struct FAsyncPackage
 

Additional Inherited Members

- Static Protected Member Functions inherited from IAsyncPackageLoader
static int32 GetNextRequestId ()
 

Detailed Description

Async loading thread. Preloads/serializes packages on async loading thread. Postloads objects on the game thread.

Constructor & Destructor Documentation

◆ FAsyncLoadingThread()

FAsyncLoadingThread::FAsyncLoadingThread ( int32  InThreadIndex)

◆ ~FAsyncLoadingThread()

FAsyncLoadingThread::~FAsyncLoadingThread ( )
virtual

Member Function Documentation

◆ CancelLoading()

void FAsyncLoadingThread::CancelLoading ( )
overridevirtual

[GAME THREAD] Cancels streaming

Implements IAsyncPackageLoader.

◆ CheckForCycles()

void FAsyncLoadingThread::CheckForCycles ( )

[EDL] [ASYNC* THREAD] Checks fopr cycles in the event driven loader and does fatal errors in that case

◆ EnterAsyncLoadingTick()

static void FAsyncLoadingThread::EnterAsyncLoadingTick ( int32  ThreadIndex)
inlinestatic

Sets the current state of async loading

◆ FindAsyncPackage()

FORCEINLINE FAsyncPackage * FAsyncLoadingThread::FindAsyncPackage ( const FName PackageName)
inline

[ASYNC THREAD] Finds an existing async package in the AsyncPackages by its name.

Parameters
PackageNameasync package name.
Returns
Pointer to the package or nullptr if not found

◆ FindLoadedPackage()

FORCEINLINE FAsyncPackage * FAsyncLoadingThread::FindLoadedPackage ( const FName PackageName)
inline

[ASYNC THREAD] Finds an existing async package in the LoadedPackages by its name.

Parameters
PackageNameasync package name.
Returns
Index of the async package in LoadedPackages array or INDEX_NONE if not found.

◆ FireCompletedCompiledInImport()

void FAsyncLoadingThread::FireCompletedCompiledInImport ( void AsyncPacakge,
FPackageIndex  Import 
)

◆ FlushLoading()

void FAsyncLoadingThread::FlushLoading ( TConstArrayView< int32 RequestIds)
overridevirtual

Flush pending loading request(s).

Note: Called from Game Thread.

Implements IAsyncPackageLoader.

◆ Get()

static FAsyncLoadingThread & FAsyncLoadingThread::Get ( )
inlinestatic

Returns the async loading thread singleton

◆ GetAsyncLoadingSuspendedCount()

FORCEINLINE int32 FAsyncLoadingThread::GetAsyncLoadingSuspendedCount ( )
inline

◆ GetAsyncLoadPercentage()

float FAsyncLoadingThread::GetAsyncLoadPercentage ( const FName PackageName)
overridevirtual

[GAME THREAD] Gets the load percentage of the specified package

Parameters
PackageNameName of the package to return async load percentage for
Returns
Percentage (0-100) of the async package load or -1 of package has not been found

Implements IAsyncPackageLoader.

◆ GetEventGraph()

FEventLoadGraph & FAsyncLoadingThread::GetEventGraph ( )
inline

Gets the EDL event graph

◆ GetIoStorePackageLoader()

IAsyncPackageLoader * FAsyncLoadingThread::GetIoStorePackageLoader ( ) const
inline

◆ GetIsInAsyncLoadingTick()

static UE_AUTORTFM_ALWAYS_OPEN bool FAsyncLoadingThread::GetIsInAsyncLoadingTick ( )
inlinestatic

Gets the current state of async loading

◆ GetLoaderType()

virtual ELoaderType FAsyncLoadingThread::GetLoaderType ( ) const
inlineoverridevirtual

Implements IAsyncPackageLoader.

◆ GetNumAsyncPackages()

FORCEINLINE int32 FAsyncLoadingThread::GetNumAsyncPackages ( )
inlineoverridevirtual

Returns the number of async packages that are currently being processed

Implements IAsyncPackageLoader.

◆ GetNumQueuedPackages()

FORCEINLINE int32 FAsyncLoadingThread::GetNumQueuedPackages ( )
inlineoverridevirtual

Returns the number of async packages that are currently queued but not yet processed

Implements IAsyncPackageLoader.

◆ GetPackage() [1/2]

FORCEINLINE FAsyncPackage * FAsyncLoadingThread::GetPackage ( FWeakAsyncPackagePtr  Ptr)
inline

[EDL] Gets a package from a weak pointer

◆ GetPackage() [2/2]

FORCEINLINE FAsyncPackage * FAsyncLoadingThread::GetPackage ( int32  PackageIndex)
inline

[ASYNC/GAME THREAD] Queues a package for streaming.

Parameters
Packagepackage descriptor.

◆ GetPrecacheHandler()

FPrecacheCallbackHandler & FAsyncLoadingThread::GetPrecacheHandler ( )
inline

Gets the EDL precache handler

◆ GetThreadIndex()

int32 FAsyncLoadingThread::GetThreadIndex ( ) const
inline

Gets this ALT index (future use)

◆ Init()

bool FAsyncLoadingThread::Init ( void  )
virtual

Initializes the runnable object.

This method is called in the context of the thread object that aggregates this, not the thread that passes this runnable to a new thread.

Returns
True if initialization was successful, false otherwise
See also
Run, Stop, Exit

Reimplemented from FRunnable.

◆ InitializeLoading()

void FAsyncLoadingThread::InitializeLoading ( )
overridevirtual

Initializes async loading thread

Implements IAsyncPackageLoader.

◆ InsertPackage()

void FAsyncLoadingThread::InsertPackage ( FAsyncPackage Package,
bool  bReinsert = false,
EAsyncPackageInsertMode  InsertMode = EAsyncPackageInsertMode::InsertBeforeMatchingPriorities 
)

[ASYNC THREAD] Inserts package to queue according to priority.

Parameters
PackageName- async package name.
InsertMode- Insert mode, describing how we insert this package into the request list

◆ IsAsyncLoadingPackages()

UE_AUTORTFM_ALWAYS_OPEN bool FAsyncLoadingThread::IsAsyncLoadingPackages ( )
inlineoverridevirtual

Returns whether packages are currently being loaded on a background thread. Note: GIsInitialLoad guards the package loader from creating background threads too early.

Implements IAsyncPackageLoader.

◆ IsAsyncLoadingSuspended()

virtual bool FAsyncLoadingThread::IsAsyncLoadingSuspended ( )
inlineoverridevirtual

Returns whether the package loader is suspended or not.

Implements IAsyncPackageLoader.

◆ IsAsyncLoadingSuspendedInternal()

FORCEINLINE bool FAsyncLoadingThread::IsAsyncLoadingSuspendedInternal ( ) const
inline

Returns true if async loading is suspended

◆ IsInAsyncLoadThread()

FORCEINLINE bool FAsyncLoadingThread::IsInAsyncLoadThread ( )
inlineoverridevirtual

Returns whether in package loader background thread or not.

Implements IAsyncPackageLoader.

◆ IsMultithreaded()

FORCEINLINE bool FAsyncLoadingThread::IsMultithreaded ( )
inlineoverridevirtual

True if multithreaded async loading is currently being used.

Implements IAsyncPackageLoader.

◆ LeaveAsyncLoadingTick()

static void FAsyncLoadingThread::LeaveAsyncLoadingTick ( int32  ThreadIndex)
inlinestatic

◆ LoadPackage() [1/2]

int32 FAsyncLoadingThread::LoadPackage ( const FPackagePath PackagePath,
FName  CustomPackageName,
FLoadPackageAsyncDelegate  InCompletionDelegate,
EPackageFlags  InPackageFlags,
int32  InPIEInstanceID,
int32  InPackagePriority,
const FLinkerInstancingContext InInstancingContext,
uint32  InLoadFlags 
)
overridevirtual

Asynchronously load a package.

Parameters
PackagePathPackagePath to load. Must be a mounted path. The package is created if it does not already exist.
CustomPackageNameIf not none, this is the name of the package to load into (and create if not yet existing). If none, the name is take from PackagePath.
InCompletionDelegateDelegate to be invoked when the packages has finished streaming
InPackageFlagsPackage flags used to construct loaded package in memory
InPIEInstanceIDPlay in Editor instance ID
InPackagePriorityLoading priority
InstancingContextAdditional context to map object names to their instanced counterpart when loading an instanced package
LoadFlagsFlags controlling loading behavior, from the ELoadFlags enum
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

Implements IAsyncPackageLoader.

◆ LoadPackage() [2/2]

int32 FAsyncLoadingThread::LoadPackage ( const FPackagePath PackagePath,
FLoadPackageAsyncOptionalParams  OptionalParams 
)
overridevirtual

Asynchronously load a package.

Parameters
PackagePathPackagePath to load. Must be a mounted path. The package is created if it does not already exist.
OptionalParamsStruct containing all the parameters required to load the package.
Returns
Unique ID associated with this load request (the same package can be associated with multiple IDs).

Reimplemented from IAsyncPackageLoader.

◆ NotifyConstructedDuringAsyncLoading()

void FAsyncLoadingThread::NotifyConstructedDuringAsyncLoading ( UObject Object,
bool  bSubObject 
)
overridevirtual

Call back into the async loading code to inform of the creation of a new object

Parameters
ObjectObject created
bSubObjectObject created as a sub-object of a loaded object

Implements IAsyncPackageLoader.

◆ NotifyRegistrationComplete()

void FAsyncLoadingThread::NotifyRegistrationComplete ( )
overridevirtual

Implements IAsyncPackageLoader.

◆ NotifyRegistrationEvent()

void FAsyncLoadingThread::NotifyRegistrationEvent ( FName  PackageName,
FName  Name,
ENotifyRegistrationType  NotifyRegistrationType,
ENotifyRegistrationPhase  NotifyRegistrationPhase,
UObject *(*)()  InRegister,
bool  InbDynamic,
UObject FinishedObject 
)
overridevirtual

Implements IAsyncPackageLoader.

◆ NotifyUnreachableObjects()

void FAsyncLoadingThread::NotifyUnreachableObjects ( const TArrayView< FUObjectItem * > &  UnreachableObjects)
inlineoverridevirtual

Implements IAsyncPackageLoader.

◆ ProcessAsyncLoading()

EAsyncPackageState::Type FAsyncLoadingThread::ProcessAsyncLoading ( int32 OutPackagesProcessed,
bool  bUseTimeLimit,
bool  bUseFullTimeLimit,
float  TimeLimit,
FFlushRequest FlushRequest 
)

[ASYNC* THREAD] Loads all packages

Parameters
OutPackagesProcessedNumber of packages processed in this call.
bUseTimeLimitTrue if time limit should be used [time-slicing].
bUseFullTimeLimitTrue if full time limit should be used [time-slicing].
TimeLimitMaximum amount of time that can be spent in this call [time-slicing].
FlushRequestThe request to flush a package and its depedencies. May be invalid.
Returns
The current state of async loading

◆ ProcessLoading()

EAsyncPackageState::Type FAsyncLoadingThread::ProcessLoading ( bool  bUseTimeLimit,
bool  bUseFullTimeLimit,
double  TimeLimit 
)
overridevirtual

Process all currently loading package requests.

Parameters
bUseTimeLimitWhether to use time limit or not
bUseFullTimeLimit
TimeLimitTime limit

Implements IAsyncPackageLoader.

◆ ProcessLoadingUntilComplete()

EAsyncPackageState::Type FAsyncLoadingThread::ProcessLoadingUntilComplete ( TFunctionRef< bool()>  CompletionPredicate,
double  TimeLimit 
)
overridevirtual

Process all loading package requests until completion predicate is satisfied.

Parameters
CompletionPredicateCompletion predicate
TimeLimitTime limit

Implements IAsyncPackageLoader.

◆ QueueEvent_CreateLinker()

void FAsyncLoadingThread::QueueEvent_CreateLinker ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues CreateLinker event

◆ QueueEvent_ExportsDone()

void FAsyncLoadingThread::QueueEvent_ExportsDone ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues ExportsDone event

◆ QueueEvent_FinishLinker()

void FAsyncLoadingThread::QueueEvent_FinishLinker ( FWeakAsyncPackagePtr  WeakPtr,
int32  EventSystemPriority = 0 
)

[EDL] Queues FinishLinker event

◆ QueueEvent_ProcessImportsAndExports()

void FAsyncLoadingThread::QueueEvent_ProcessImportsAndExports ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues ProcessImportsAndExports event

◆ QueueEvent_ProcessPostloadWait()

void FAsyncLoadingThread::QueueEvent_ProcessPostloadWait ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues ProcessPostload event

◆ QueueEvent_SetupExports()

void FAsyncLoadingThread::QueueEvent_SetupExports ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues SetupExports event

◆ QueueEvent_SetupImports()

void FAsyncLoadingThread::QueueEvent_SetupImports ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues SetupImports event

◆ QueueEvent_StartImportPackages()

void FAsyncLoadingThread::QueueEvent_StartImportPackages ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues StartImportPackages event

◆ QueueEvent_StartPostLoad()

void FAsyncLoadingThread::QueueEvent_StartPostLoad ( FAsyncPackage Pkg,
int32  EventSystemPriority = 0 
)

[EDL] Queues StartPostLoad event

◆ QueuePackage()

void FAsyncLoadingThread::QueuePackage ( FAsyncPackageDesc Package)

[ASYNC/GAME THREAD] Queues a package for streaming.

Parameters
Packagepackage descriptor.

◆ ResumeLoading()

void FAsyncLoadingThread::ResumeLoading ( )
overridevirtual

[GAME THREAD] Resumes async loading thread

Implements IAsyncPackageLoader.

◆ Run()

uint32 FAsyncLoadingThread::Run ( )
virtual

Runs the runnable object.

This is where all per object thread work is done. This is only called if the initialization was successful.

Returns
The exit code of the runnable object
See also
Init, Stop, Exit

Implements FRunnable.

◆ SetIoStorePackageLoader()

void FAsyncLoadingThread::SetIoStorePackageLoader ( IAsyncPackageLoader InIoStorePackageLoader)
inline

◆ ShouldAlwaysLoadPackageAsync()

bool FAsyncLoadingThread::ShouldAlwaysLoadPackageAsync ( const FPackagePath InPackagePath)
overridevirtual

Implements IAsyncPackageLoader.

◆ ShutdownLoading()

void FAsyncLoadingThread::ShutdownLoading ( )
overridevirtual

[GAME THREAD] Stops the async loading thread and blocks until the thread has exited.

Implements IAsyncPackageLoader.

◆ StartThread()

void FAsyncLoadingThread::StartThread ( )
overridevirtual

Start the async loading thread

Implements IAsyncPackageLoader.

◆ Stop()

void FAsyncLoadingThread::Stop ( void  )
virtual

Stops the runnable object.

This is called if a thread is requested to terminate early.

See also
Init, Run, Exit

Reimplemented from FRunnable.

◆ SuspendLoading()

void FAsyncLoadingThread::SuspendLoading ( )
overridevirtual

[GAME THREAD] Suspends async loading thread

Implements IAsyncPackageLoader.

◆ TickAsyncLoading()

EAsyncPackageState::Type FAsyncLoadingThread::TickAsyncLoading ( bool  bUseTimeLimit,
bool  bUseFullTimeLimit,
double  TimeLimit,
FFlushRequest  FlushRequest = FFlushRequest() 
)

[GAME THREAD] Ticks game thread side of async loading.

Parameters
bUseTimeLimitTrue if time limit should be used [time-slicing].
bUseFullTimeLimitTrue if full time limit should be used [time-slicing].
TimeLimitMaximum amount of time that can be spent in this call [time-slicing].
FlushRequestThe request to flush a package and its depedencies. May be invalid.
Returns
The current state of async loading

◆ TickAsyncThread()

EAsyncPackageState::Type FAsyncLoadingThread::TickAsyncThread ( bool  bUseTimeLimit,
bool  bUseFullTimeLimit,
double  TimeLimit,
bool bDidSomething,
FFlushRequest FlushRequest 
)

[ASYNC THREAD] Main thread loop

Parameters
bUseTimeLimitTrue if time limit should be used [time-slicing].
bUseFullTimeLimitTrue if full time limit should be used [time-slicing].
TimeLimitMaximum amount of time that can be spent in this call [time-slicing].
FlushRequestThe request to flush a package and its depedencies. May be invalid.

Friends And Related Symbol Documentation

◆ FAsyncPackage

Member Data Documentation

◆ AsyncPackagesReadyForTick

TArray<FAsyncPackage*> FAsyncLoadingThread::AsyncPackagesReadyForTick

[EDL] Async Packages that are ready for tick

◆ EventQueue

FAsyncLoadEventQueue FAsyncLoadingThread::EventQueue

[EDL] Event queue

◆ Instance

FAsyncLoadingThread * FAsyncLoadingThread::Instance = nullptr
static

◆ RecursionNotAllowed

FThreadSafeCounter FAsyncLoadingThread::RecursionNotAllowed

The documentation for this class was generated from the following files: