UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FTaskGraphInterface Class Referenceabstract

#include <TaskGraphInterfaces.h>

+ Inheritance diagram for FTaskGraphInterface:

Public Types

enum class  EProcessTasksOperation : int8 {
  ProcessAllOtherTasks , ProcessOneOtherTask , ProcessNamedThreadTasks , WaitUntilComplete ,
  StopProcessing
}
 
typedef TFunction< EProcessTasksOperation(int32)> FProcessTasksUpdateCallback
 

Public Member Functions

virtual ~FTaskGraphInterface ()
 
virtual ENamedThreads::Type GetCurrentThreadIfKnown (bool bLocalQueue=false)=0
 
virtual bool IsCurrentThreadKnown ()=0
 
virtual int32 GetNumWorkerThreads ()=0
 
virtual int32 GetNumForegroundThreads ()=0
 
virtual int32 GetNumBackgroundThreads ()=0
 
virtual bool IsThreadProcessingTasks (ENamedThreads::Type ThreadToCheck)=0
 
virtual void AttachToThread (ENamedThreads::Type CurrentThread)=0
 
virtual uint64 ProcessThreadUntilIdle (ENamedThreads::Type CurrentThread)=0
 
virtual void ProcessThreadUntilRequestReturn (ENamedThreads::Type CurrentThread)=0
 
virtual void RequestReturn (ENamedThreads::Type CurrentThread)=0
 
virtual void WaitUntilTasksComplete (const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)=0
 
virtual bool ProcessUntilTasksComplete (const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown, const FProcessTasksUpdateCallback &IdleWorkUpdate={})=0
 
virtual void TriggerEventWhenTasksComplete (FEvent *InEvent, const FGraphEventArray &Tasks, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type TriggerThread=ENamedThreads::AnyHiPriThreadHiPriTask)=0
 
void WaitUntilTaskCompletes (const FGraphEventRef &Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
 
void WaitUntilTaskCompletes (FGraphEventRef &&Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread)
 
void TriggerEventWhenTaskCompletes (FEvent *InEvent, const FGraphEventRef &Task, ENamedThreads::Type CurrentThreadIfKnown=ENamedThreads::AnyThread, ENamedThreads::Type TriggerThread=ENamedThreads::AnyHiPriThreadHiPriTask)
 
virtual FBaseGraphTaskFindWork (ENamedThreads::Type ThreadInNeed)=0
 
virtual void StallForTuning (int32 Index, bool Stall)=0
 
virtual void AddShutdownCallback (TFunction< void()> &Callback)=0
 
virtual void WakeNamedThread (ENamedThreads::Type ThreadToWake)=0
 

Static Public Member Functions

static CORE_API void Startup (int32 NumThreads)
 
static CORE_API void Shutdown ()
 
static CORE_API bool IsRunning ()
 
static CORE_API FTaskGraphInterfaceGet ()
 
static bool IsMultithread ()
 
static void BroadcastSlow_OnlyUseForSpecialPurposes (bool bDoTaskThreads, bool bDoBackgroundThreads, TFunction< void(ENamedThreads::Type CurrentThread)> &Callback)
 

Friends

class FBaseGraphTask
 

Detailed Description

Interface to the task graph system

Member Typedef Documentation

◆ FProcessTasksUpdateCallback

Function periodically called during task processing, with parameter set to number of tasks remaining

Member Enumeration Documentation

◆ EProcessTasksOperation

Used to define what ProcessUntilTasksComplete should do next

Enumerator
ProcessAllOtherTasks 

Default behavior with no update callback, try to process all other thread thread tasks in the queue before checking named thread tasks

ProcessOneOtherTask 

Try to process other thread tasks, but immediately process named thread tasks after completing one

ProcessNamedThreadTasks 

Immediately try to process named thread tasks and call update again

WaitUntilComplete 

Stop any idle processing and wait on this thread until all tasks are complete, update is not called again

StopProcessing 

Stop processing entirely and return, like if ProcessingTimeout has expired

Constructor & Destructor Documentation

◆ ~FTaskGraphInterface()

virtual FTaskGraphInterface::~FTaskGraphInterface ( )
inlinevirtual

Member Function Documentation

◆ AddShutdownCallback()

virtual void FTaskGraphInterface::AddShutdownCallback ( TFunction< void()> &  Callback)
pure virtual

Delegates for shutdown

Parameters
Callback- function to call prior to shutting down the taskgraph

◆ AttachToThread()

virtual void FTaskGraphInterface::AttachToThread ( ENamedThreads::Type  CurrentThread)
pure virtual

A one time call that "introduces" an external thread to the system. Basically, it just sets up the TLS info

Parameters
CurrentThread;The name of the current thread.

◆ BroadcastSlow_OnlyUseForSpecialPurposes()

void FTaskGraphInterface::BroadcastSlow_OnlyUseForSpecialPurposes ( bool  bDoTaskThreads,
bool  bDoBackgroundThreads,
TFunction< void(ENamedThreads::Type CurrentThread)> &  Callback 
)
static

A (slow) function to call a function on every known thread, both named and workers

Parameters
Callback- function to call prior to shutting down the taskgraph

◆ FindWork()

virtual FBaseGraphTask * FTaskGraphInterface::FindWork ( ENamedThreads::Type  ThreadInNeed)
pure virtual

◆ Get()

FTaskGraphInterface & FTaskGraphInterface::Get ( )
static

Singleton for the system

Returns
a reference to the task graph system

◆ GetCurrentThreadIfKnown()

virtual ENamedThreads::Type FTaskGraphInterface::GetCurrentThreadIfKnown ( bool  bLocalQueue = false)
pure virtual

Return the current thread type, if known.

◆ GetNumBackgroundThreads()

virtual int32 FTaskGraphInterface::GetNumBackgroundThreads ( )
pure virtual

Return the number of background worker threads. If the old backend is used, return the number of background workers (0 if background workers are disabled).

◆ GetNumForegroundThreads()

virtual int32 FTaskGraphInterface::GetNumForegroundThreads ( )
pure virtual

Return the number of foreground worker threads. If the old backend is used, return the number of high-pri workers (0 if high-pri workers are disabled).

◆ GetNumWorkerThreads()

virtual int32 FTaskGraphInterface::GetNumWorkerThreads ( )
pure virtual

Return the number of worker (non-named) threads PER PRIORITY SET. This is useful for determining how many tasks to split a job into.

◆ IsCurrentThreadKnown()

virtual bool FTaskGraphInterface::IsCurrentThreadKnown ( )
pure virtual

Return true if the current thread is known.

◆ IsMultithread()

bool FTaskGraphInterface::IsMultithread ( )
static

The task graph is always multi-threaded for platforms that support it. For forked processes, the taskgraph will be singlethread for the master process but becomes multithread in the forked process

◆ IsRunning()

bool FTaskGraphInterface::IsRunning ( )
static

Check to see if the system is running.

◆ IsThreadProcessingTasks()

virtual bool FTaskGraphInterface::IsThreadProcessingTasks ( ENamedThreads::Type  ThreadToCheck)
pure virtual

Return true if the given named thread is processing tasks. This is only a "guess" if you ask for a thread other than yourself because that can change before the function returns.

◆ ProcessThreadUntilIdle()

virtual uint64 FTaskGraphInterface::ProcessThreadUntilIdle ( ENamedThreads::Type  CurrentThread)
pure virtual

Requests that a named thread, which must be this thread, run until idle, then return.

Parameters
CurrentThread;The name of this thread

◆ ProcessThreadUntilRequestReturn()

virtual void FTaskGraphInterface::ProcessThreadUntilRequestReturn ( ENamedThreads::Type  CurrentThread)
pure virtual

Requests that a named thread, which must be this thread, run until an explicit return request is received, then return.

Parameters
CurrentThread;The name of this thread

◆ ProcessUntilTasksComplete()

virtual bool FTaskGraphInterface::ProcessUntilTasksComplete ( const FGraphEventArray Tasks,
ENamedThreads::Type  CurrentThreadIfKnown,
const FProcessTasksUpdateCallback IdleWorkUpdate = {} 
)
pure virtual

Requests that a named thread actively attempt to process a list of tasks and periodically call an update function when idle. This function assumes that many of the tasks can be completed on this thread.

Parameters
Tasks- tasks to wait for
CurrentThread- This thread, must be a named thread
IdleWorkUpdate- If set, call this function after trying to process named thread work if any tasks are stalled
Returns
true if all tasks were completed, return false if StopProcessing was returned or it failed to process all tasks

◆ RequestReturn()

virtual void FTaskGraphInterface::RequestReturn ( ENamedThreads::Type  CurrentThread)
pure virtual

Request that the given thread stop when it is idle

◆ Shutdown()

void FTaskGraphInterface::Shutdown ( )
static

Explicit start call to shutdown the system. This is unlikely to work unless the system is idle.

◆ StallForTuning()

virtual void FTaskGraphInterface::StallForTuning ( int32  Index,
bool  Stall 
)
pure virtual

◆ Startup()

void FTaskGraphInterface::Startup ( int32  NumThreads)
static

Explicit start call for the system. The ordinary singleton pattern does not work because internal threads start asking for the singleton before the constructor has returned.

Parameters
NumThreads;Total number of threads in the system, must be 0 to disable separate taskgraph thread, at least 2 if !threadedrendering, else at least 3

◆ TriggerEventWhenTaskCompletes()

void FTaskGraphInterface::TriggerEventWhenTaskCompletes ( FEvent InEvent,
const FGraphEventRef Task,
ENamedThreads::Type  CurrentThreadIfKnown = ENamedThreads::AnyThread,
ENamedThreads::Type  TriggerThread = ENamedThreads::AnyHiPriThreadHiPriTask 
)
inline

When a task completes, fire a scoped event

Parameters
InEvent- event to fire when the task is done
Task- task to wait for
CurrentThreadIfKnown- This thread, if known

◆ TriggerEventWhenTasksComplete()

virtual void FTaskGraphInterface::TriggerEventWhenTasksComplete ( FEvent InEvent,
const FGraphEventArray Tasks,
ENamedThreads::Type  CurrentThreadIfKnown = ENamedThreads::AnyThread,
ENamedThreads::Type  TriggerThread = ENamedThreads::AnyHiPriThreadHiPriTask 
)
pure virtual

When a set of tasks complete, fire a scoped event

Parameters
InEvent- event to fire when the task is done
Tasks- tasks to wait for
CurrentThreadIfKnown- This thread, if known

◆ WaitUntilTaskCompletes() [1/2]

void FTaskGraphInterface::WaitUntilTaskCompletes ( const FGraphEventRef Task,
ENamedThreads::Type  CurrentThreadIfKnown = ENamedThreads::AnyThread 
)
inline

Requests that a named thread, which must be this thread, run until a task is complete

Parameters
Task- task to wait for
CurrentThread- This thread, must be a named thread

◆ WaitUntilTaskCompletes() [2/2]

void FTaskGraphInterface::WaitUntilTaskCompletes ( FGraphEventRef &&  Task,
ENamedThreads::Type  CurrentThreadIfKnown = ENamedThreads::AnyThread 
)
inline

◆ WaitUntilTasksComplete()

virtual void FTaskGraphInterface::WaitUntilTasksComplete ( const FGraphEventArray Tasks,
ENamedThreads::Type  CurrentThreadIfKnown = ENamedThreads::AnyThread 
)
pure virtual

Requests that a named thread, which must be this thread, run until a list of tasks is complete. This function assumes that most of the tasks will be processed on a different thread, but will process if needed.

Parameters
Tasks- tasks to wait for
CurrentThread- This thread, must be a named thread

◆ WakeNamedThread()

virtual void FTaskGraphInterface::WakeNamedThread ( ENamedThreads::Type  ThreadToWake)
pure virtual

Friends And Related Symbol Documentation

◆ FBaseGraphTask

friend class FBaseGraphTask
friend

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