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

Public Member Functions

 FForkableThread (bool InAllowPreForkRealThread)
 
virtual ~FForkableThread ()
 
virtual void Tick () override
 
virtual void SetThreadPriority (EThreadPriority NewPriority) override
 
virtual void Suspend (bool bShouldPause) override
 
virtual bool Kill (bool bShouldWait) override
 
virtual void WaitForCompletion () override
 
virtual FRunnableThread::ThreadType GetThreadType () const override
 
virtual bool CreateInternal (FRunnable *InRunnable, const TCHAR *InThreadName, uint32 InStackSize, EThreadPriority InThreadPri, uint64 InThreadAffinityMask, EThreadCreateFlags InCreateFlags) override
 
- Public Member Functions inherited from FFakeThread
 FFakeThread ()
 
virtual ~FFakeThread ()
 
- Public Member Functions inherited from FRunnableThread
virtual bool SetThreadAffinity (const FThreadAffinity &Affinity)
 
const uint32 GetThreadID () const
 
const FString & GetThreadName () const
 
EThreadPriority GetThreadPriority () const
 
CORE_API FRunnableThread ()
 
virtual CORE_API ~FRunnableThread ()
 

Protected Member Functions

virtual void OnPreFork () override
 
virtual void OnPostFork () override
 
bool CreateRealThread ()
 
- Protected Member Functions inherited from FRunnableThread
CORE_API void SetTls ()
 
CORE_API void FreeTls ()
 

Protected Attributes

bool bAllowPreForkRealThread
 
- Protected Attributes inherited from FFakeThread
bool bIsSuspended
 
FSingleThreadRunnableSingleThreadRunnable
 
- Protected Attributes inherited from FRunnableThread
FString ThreadName
 
FRunnableRunnable
 
FEventThreadInitSyncEvent
 
uint64 ThreadAffinityMask
 
EThreadPriority ThreadPriority
 
uint32 ThreadID
 

Additional Inherited Members

- Public Types inherited from FRunnableThread
enum class  ThreadType { Real , Fake , Forkable }
 
- Static Public Member Functions inherited from FRunnableThread
static CORE_API uint32 GetTlsSlot ()
 
static CORE_API FRunnableThreadCreate (class FRunnable *InRunnable, const TCHAR *ThreadName, uint32 InStackSize=0, EThreadPriority InThreadPri=TPri_Normal, uint64 InThreadAffinityMask=FPlatformAffinity::GetNoAffinityMask(), EThreadCreateFlags InCreateFlags=EThreadCreateFlags::None)
 
static FRunnableThreadGetRunnableThread ()
 
- Static Public Attributes inherited from FFakeThread
static constexpr uint32 FakeIdReservedBit = 1 << 31
 

Detailed Description

This thread starts as a fake thread and gets ticked like it was in a single-threaded environment. Once it receives the OnPostFork event it creates and holds a real thread that will cause the RunnableObject to be executed in it's own thread. Optionally, it can create the real thread immediately, but it also asserts that the real thread has exited by the fork point.

Constructor & Destructor Documentation

◆ FForkableThread()

FForkableThread::FForkableThread ( bool  InAllowPreForkRealThread)
inline

◆ ~FForkableThread()

virtual FForkableThread::~FForkableThread ( )
inlinevirtual

Member Function Documentation

◆ CreateInternal()

virtual bool FForkableThread::CreateInternal ( FRunnable InRunnable,
const TCHAR InThreadName,
uint32  InStackSize,
EThreadPriority  InThreadPri,
uint64  InThreadAffinityMask,
EThreadCreateFlags  InCreateFlags 
)
inlineoverridevirtual

Creates the thread with the specified stack size and thread priority.

Parameters
InRunnableThe runnable object to execute
ThreadNameName of the thread
InStackSizeThe size of the stack to create. 0 means use the current thread's stack size
InThreadPriTells the thread whether it needs to adjust its priority or not. Defaults to normal priority
Returns
True if the thread and all of its initialization was successful, false otherwise

Reimplemented from FFakeThread.

◆ CreateRealThread()

bool FForkableThread::CreateRealThread ( )
inlineprotected

◆ GetThreadType()

virtual FRunnableThread::ThreadType FForkableThread::GetThreadType ( ) const
inlineoverridevirtual

Returns the type of thread this is

Reimplemented from FFakeThread.

◆ Kill()

virtual bool FForkableThread::Kill ( bool  bShouldWait)
inlineoverridevirtual

Tells the thread to exit. If the caller needs to know when the thread has exited, it should use the bShouldWait value. It's highly recommended not to kill the thread without waiting for it. Having a thread forcibly destroyed can cause leaks and deadlocks.

The kill method is calling Stop() on the runnable to kill the thread gracefully.

Parameters
bShouldWaitIf true, the call will wait infinitely for the thread to exit.
Returns
Always true

Reimplemented from FFakeThread.

◆ OnPostFork()

virtual void FForkableThread::OnPostFork ( )
inlineoverrideprotectedvirtual

Called on the forked process when the forkable thread can create a real thread

Reimplemented from FRunnableThread.

◆ OnPreFork()

virtual void FForkableThread::OnPreFork ( )
inlineoverrideprotectedvirtual

Called on the parent process before the fork occurs

Reimplemented from FRunnableThread.

◆ SetThreadPriority()

virtual void FForkableThread::SetThreadPriority ( EThreadPriority  NewPriority)
inlineoverridevirtual

Changes the thread priority of the currently running thread

Parameters
NewPriorityThe thread priority to change to

Reimplemented from FFakeThread.

◆ Suspend()

virtual void FForkableThread::Suspend ( bool  bShouldPause)
inlineoverridevirtual

Tells the thread to either pause execution or resume depending on the passed in value.

Parameters
bShouldPauseWhether to pause the thread (true) or resume (false)

Reimplemented from FFakeThread.

◆ Tick()

virtual void FForkableThread::Tick ( )
inlineoverridevirtual

Tick one time per frame.

Reimplemented from FFakeThread.

◆ WaitForCompletion()

virtual void FForkableThread::WaitForCompletion ( )
inlineoverridevirtual

Halts the caller until this thread is has completed its work.

Reimplemented from FFakeThread.

Member Data Documentation

◆ bAllowPreForkRealThread

bool FForkableThread::bAllowPreForkRealThread
protected

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