UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FTaskThreadBase Class Referenceabstract
+ Inheritance diagram for FTaskThreadBase:

Public Member Functions

 FTaskThreadBase ()
 
void Setup (ENamedThreads::Type InThreadId, uint32 InPerThreadIDTLSSlot, FWorkerThread *InOwnerWorker)
 
void InitializeForCurrentThread ()
 
ENamedThreads::Type GetThreadId () const
 
virtual void ProcessTasksUntilQuit (int32 QueueIndex)=0
 
virtual uint64 ProcessTasksUntilIdle (int32 QueueIndex)
 
virtual void EnqueueFromThisThread (int32 QueueIndex, FBaseGraphTask *Task)
 
virtual void RequestQuit (int32 QueueIndex)=0
 
virtual bool EnqueueFromOtherThread (int32 QueueIndex, FBaseGraphTask *Task)
 
virtual void WakeUp (int32 QueueIndex=0)=0
 
virtual bool IsProcessingTasks (int32 QueueIndex)=0
 
virtual void Tick () override
 
virtual bool Init () override
 
virtual uint32 Run () override
 
virtual void Stop () override
 
virtual void Exit () override
 
virtual FSingleThreadRunnableGetSingleThreadInterface () override
 
- Public Member Functions inherited from FRunnable
virtual ~FRunnable ()
 

Protected Attributes

ENamedThreads::Type ThreadId
 
uint32 PerThreadIDTLSSlot
 
FThreadSafeCounter IsStalled
 
TArray< FBaseGraphTask * > NewTasks
 
FWorkerThreadOwnerWorker
 

Detailed Description

FTaskThreadBase Base class for a thread that executes tasks This class implements the FRunnable API, but external threads don't use that because those threads are created elsewhere.

Constructor & Destructor Documentation

◆ FTaskThreadBase()

FTaskThreadBase::FTaskThreadBase ( )
inline

Constructor, initializes everything to unusable values. Meant to be called from a "main" thread.

Member Function Documentation

◆ EnqueueFromOtherThread()

virtual bool FTaskThreadBase::EnqueueFromOtherThread ( int32  QueueIndex,
FBaseGraphTask Task 
)
inlinevirtual

Queue a task, assuming that this thread is not the same as the current thread.

Parameters
QueueIndex,Queueto enqueue into
Task;Task to queue.

Reimplemented in FNamedTaskThread.

◆ EnqueueFromThisThread()

virtual void FTaskThreadBase::EnqueueFromThisThread ( int32  QueueIndex,
FBaseGraphTask Task 
)
inlinevirtual

Queue a task, assuming that this thread is the same as the current thread. For named threads, these go directly into the private queue.

Parameters
QueueIndex,Queueto enqueue for
TaskTask to queue.

Reimplemented in FNamedTaskThread.

◆ Exit()

virtual void FTaskThreadBase::Exit ( void  )
inlineoverridevirtual

Called in the context of the aggregating thread to perform any cleanup.

Reimplemented from FRunnable.

◆ GetSingleThreadInterface()

virtual FSingleThreadRunnable * FTaskThreadBase::GetSingleThreadInterface ( )
inlineoverridevirtual

Return single threaded interface when multithreading is disabled.

Reimplemented from FRunnable.

◆ GetThreadId()

ENamedThreads::Type FTaskThreadBase::GetThreadId ( ) const
inline

Return the index of this thread.

◆ Init()

virtual bool FTaskThreadBase::Init ( void  )
inlineoverridevirtual

Allows per runnable object initialization. NOTE: This 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

Reimplemented from FRunnable.

◆ InitializeForCurrentThread()

void FTaskThreadBase::InitializeForCurrentThread ( )
inline

A one-time call to set the TLS entry for this thread.

◆ IsProcessingTasks()

virtual bool FTaskThreadBase::IsProcessingTasks ( int32  QueueIndex)
pure virtual

Return true if this 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.

Parameters
QueueIndex,Queueto request quit from

Implemented in FNamedTaskThread, and FTaskThreadAnyThread.

◆ ProcessTasksUntilIdle()

virtual uint64 FTaskThreadBase::ProcessTasksUntilIdle ( int32  QueueIndex)
inlinevirtual

Used for named threads to start processing tasks until the thread is idle and RequestQuit has been called.

Reimplemented in FNamedTaskThread, and FTaskThreadAnyThread.

◆ ProcessTasksUntilQuit()

virtual void FTaskThreadBase::ProcessTasksUntilQuit ( int32  QueueIndex)
pure virtual

Used for named threads to start processing tasks until the thread is idle and RequestQuit has been called.

Implemented in FNamedTaskThread, and FTaskThreadAnyThread.

◆ RequestQuit()

virtual void FTaskThreadBase::RequestQuit ( int32  QueueIndex)
pure virtual

Will cause the thread to return to the caller when it becomes idle. Used to return from ProcessTasksUntilQuit for named threads or to shut down unnamed threads. CAUTION: This will not work under arbitrary circumstances. For example you should not attempt to stop unnamed threads unless they are known to be idle. Return requests for named threads should be submitted from that named thread as FReturnGraphTask does.

Parameters
QueueIndex,Queueto request quit from

Implemented in FNamedTaskThread, and FTaskThreadAnyThread.

◆ Run()

virtual uint32 FTaskThreadBase::Run ( void  )
inlineoverridevirtual

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

Implements FRunnable.

◆ Setup()

void FTaskThreadBase::Setup ( ENamedThreads::Type  InThreadId,
uint32  InPerThreadIDTLSSlot,
FWorkerThread InOwnerWorker 
)
inline

Sets up some basic information for a thread. Meant to be called from a "main" thread. Also creates the stall event.

Parameters
InThreadId;Thread index for this thread.
InPerThreadIDTLSSlot;TLS slot to store the pointer to me into (later)

◆ Stop()

virtual void FTaskThreadBase::Stop ( void  )
inlineoverridevirtual

This is called if a thread is requested to terminate early

Reimplemented from FRunnable.

◆ Tick()

virtual void FTaskThreadBase::Tick ( )
inlineoverridevirtual

Tick single-threaded.

Implements FSingleThreadRunnable.

◆ WakeUp()

virtual void FTaskThreadBase::WakeUp ( int32  QueueIndex = 0)
pure virtual

Implemented in FNamedTaskThread, and FTaskThreadAnyThread.

Member Data Documentation

◆ IsStalled

FThreadSafeCounter FTaskThreadBase::IsStalled
protected

Used to signal stalling. Not safe for synchronization in most cases.

◆ NewTasks

TArray<FBaseGraphTask*> FTaskThreadBase::NewTasks
protected

Array of tasks for this task thread.

◆ OwnerWorker

FWorkerThread* FTaskThreadBase::OwnerWorker
protected

back pointer to the owning FWorkerThread

◆ PerThreadIDTLSSlot

uint32 FTaskThreadBase::PerThreadIDTLSSlot
protected

TLS SLot that we store the FTaskThread* this pointer in.

◆ ThreadId

ENamedThreads::Type FTaskThreadBase::ThreadId
protected

Id / Index of this thread.


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