Navigation
Unreal Engine C++ API Reference > Runtime > Core > HAL
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
Type | Name | Description | |
---|---|---|---|
![]() |
FThread () |
Creates new "empty" thread object that doesn't represent a system thread | |
![]() |
Non-copyable | ||
![]() |
|||
![]() |
FThread
(
TCHAR const* ThreadName, |
Creates and immediately starts a new system thread that will execute `ThreadFunction_ argument. | |
![]() |
FThread
(
TCHAR const* ThreadName, |
With SingleThreadTickFunction that will be executed every frame if running with `-nothreading (FPlatformProcess::SupportsMultithreading() == false) |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
~FThread () |
Destructor asserts if the instance is not joined or detached. |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
uint32 | GetThreadId () |
|
![]() ![]() |
bool | IsJoinable () |
Checks if the thread object identifies an active thread of execution. |
![]() |
void | Join () |
Blocks the current thread until the thread identified by `this_ finishes its execution. |
Operators
Type | Name | Description | |
---|---|---|---|
![]() |
FThread & | ||
![]() |
FThread & | Move assignment operator. Asserts if the instance is joinable. |
Enums
Type | Name | Description | |
---|---|---|---|
![]() |
EForkable | Indicates if the thread should be forked in case the owning process is forked |
Constants
Name | Description |
---|---|
InvalidThreadId |