FThread

Simple API for system threads.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/HAL/Thread.h

Include

#include "HAL/Thread.h"

Syntax

class FThread

Remarks

Simple API for system threads. Before using, please make sure you really need a new system thread. By default and in the majority of cases parallel processing should be done by TaskGraph. For richer functionality check [FRunnable](API\Runtime\Core\HAL\FRunnable)_/FRunnableThread. It's up to user to provide a way to notify the thread function to exit on demand. Before destroying the instance it must be either Join_ed or Detach_ed. Example: FThread Thread{TEXT("New thread"), []() { do_something_important(); }}; ... continue in the caller thread Thread.Join(); For more verbose example check `TestTypicalUseCase in `ThreadTest.cpp_

Constructors

Name Description

Public function

FThread()

Creates new "empty" thread object that doesn't represent a system thread

Public function

FThread

(
    const FThread&
)

Non-copyable

Public function

FThread

(
    FThread&&
)

Public function

FThread

(
    TCHAR const* ThreadName,
    TUniqueFunction< void()>&& ThreadF...,
    uint32 StackSize,
    EThreadPriority ThreadPriority,
    uint64 ThreadAffinityMask
)

Creates and immediately starts a new system thread that will execute `ThreadFunction_ argument.

Destructors

Name Description

Public function

~FThread()

Destructor asserts if the instance is not joined or detached.

Functions

Name Description

Public function Const

uint32

 

GetThreadId()

Public function Const

bool

 

IsJoinable()

Checks if the thread object identifies an active thread of execution.

Public function

void

 

Join()

Blocks the current thread until the thread identified by `this_ finishes its execution.

Operators

Name Description

Public function

FThread &

 

operator=

(
    const FThread&
)

Public function

FThread &

 

operator=

(
    FThread&& Other
)

Move assignment operator. Asserts if the instance is joinable.

Constants

Name

Description

InvalidThreadId

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss