engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
FThread类 参考final

Simple API for system threads. 更多...

#include <Thread.h>

Public 成员函数

 FThread ()
 Creates new "empty" thread object that doesn't represent a system thread
 
 FThread (TCHAR const *ThreadName, TUniqueFunction< void()> &&ThreadFunction, uint32 StackSize=0, EThreadPriority ThreadPriority=TPri_Normal, uint64 ThreadAffinityMask=FPlatformAffinity::GetNoAffinityMask())
 Creates and immediately starts a new system thread that will execute ThreadFunction argument. 更多...
 
uint32 GetThreadId () const
 
bool IsJoinable () const
 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. 更多...
 
FThread & operator= (FThread &&Other)
 Move assignment operator. 更多...
 
 ~FThread ()
 Destructor asserts if the instance is not joined or detached.
 

详细描述

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/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 Joined or Detached. 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

构造及析构函数说明

◆ FThread()

FThread::FThread ( TCHAR const *  ThreadName,
TUniqueFunction< void()> &&  ThreadFunction,
uint32  StackSize = 0,
EThreadPriority  ThreadPriority = TPri_Normal,
uint64  ThreadAffinityMask = FPlatformAffinity::GetNoAffinityMask() 
)

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

Can return before the thread is actually started or when it already finished execution.

参数
ThreadNameName of the thread
ThreadFunctionThe function that will be executed by the newly created thread
StackSizeThe size of the stack to create. 0 means use the current thread's stack size
ThreadPriorityTells the thread whether it needs to adjust its priority or not. Defaults to normal priority

成员函数说明

◆ GetThreadId()

uint32 FThread::GetThreadId ( ) const
返回
Thread ID for this thread

◆ IsJoinable()

bool FThread::IsJoinable ( ) const

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

A thread that has finished executing code, but has not yet been joined is still considered an active thread of execution and is therefore joinable.

参见
Join

◆ Join()

void FThread::Join ( )

Blocks the current thread until the thread identified by this finishes its execution.

The completion of the thread identified by this synchronizes with the corresponding successful return from Join(). No synchronization is performed on this itself. Concurrently calling Join() on the same FThread object from multiple threads constitutes a data race that results in undefined behavior.

参见
IsJoinable

◆ operator=()

FThread & FThread::operator= ( FThread &&  Other)

Move assignment operator.

Asserts if the instance is joinable.


该类的文档由以下文件生成: