engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 静态 Public 成员函数 | Protected 类型 | Protected 成员函数 | 静态 Protected 成员函数 | Protected 属性 | 友元 | 所有成员列表
FRunnableThread类 参考abstract

Interface for runnable threads. 更多...

#include <RunnableThread.h>

Public 成员函数

 FRunnableThread ()
 Default constructor.
 
const uint32 GetThreadID () const
 Thread ID for this thread 更多...
 
const FString & GetThreadName () const
 Retrieves the given name of the thread 更多...
 
EThreadPriority GetThreadPriority () const
 Returns the runnable's thread priority
 
virtual bool Kill (bool bShouldWait=true)=0
 Tells the thread to exit. 更多...
 
virtual void SetThreadPriority (EThreadPriority NewPriority)=0
 Changes the thread priority of the currently running thread 更多...
 
virtual void Suspend (bool bShouldPause=true)=0
 Tells the thread to either pause execution or resume depending on the passed in value. 更多...
 
virtual void WaitForCompletion ()=0
 Halts the caller until this thread is has completed its work.
 
virtual ~FRunnableThread ()
 Virtual destructor
 

静态 Public 成员函数

static FRunnableThread * Create (class FRunnable *InRunnable, const TCHAR *ThreadName, uint32 InStackSize=0, EThreadPriority InThreadPri=TPri_Normal, uint64 InThreadAffinityMask=FPlatformAffinity::GetNoAffinityMask(), EThreadCreateFlags InCreateFlags=EThreadCreateFlags::None)
 Factory method to create a thread with the specified stack size and thread priority. 更多...
 
static uint32 GetTlsSlot ()
 Gets a new Tls slot for storing the runnable thread pointer.
 

Protected 类型

enum class  ThreadType
 List of unique thread types we can create
 

Protected 成员函数

virtual bool CreateInternal (FRunnable *InRunnable, const TCHAR *InThreadName, uint32 InStackSize=0, EThreadPriority InThreadPri=TPri_Normal, uint64 InThreadAffinityMask=0, EThreadCreateFlags InCreateFlags=EThreadCreateFlags::None)=0
 Creates the thread with the specified stack size and thread priority. 更多...
 
void FreeTls ()
 Deletes all FTlsAutoCleanup objects created for this thread.
 
void SetTls ()
 Stores this instance in the runnable thread TLS slot.
 

静态 Protected 成员函数

static FRunnableThread * GetRunnableThread ()
 

Protected 属性

FRunnable * Runnable
 The runnable object to execute on this thread.
 
uint64 ThreadAffinityMask
 The Affinity to run the thread with.
 
uint32 ThreadID
 ID set during thread creation.
 
FEvent * ThreadInitSyncEvent
 Sync event to make sure that Init() has been completed before allowing the main thread to continue.
 
FString ThreadName
 Holds the name of the thread.
 
EThreadPriority ThreadPriority
 The priority to run the thread at.
 
TArray< FTlsAutoCleanup * > TlsInstances
 An array of FTlsAutoCleanup based instances that needs to be deleted before the thread will die.
 

友元

class FForkProcessHelper
 
class FThreadManager
 
class FThreadSingletonInitializer
 
class FTlsAutoCleanup
 

详细描述

Interface for runnable threads.

This interface specifies the methods used to manage a thread's life cycle.

成员函数说明

◆ Create()

static FRunnableThread * FRunnableThread::Create ( class FRunnable *  InRunnable,
const TCHAR *  ThreadName,
uint32  InStackSize = 0,
EThreadPriority  InThreadPri = TPri_Normal,
uint64  InThreadAffinityMask = FPlatformAffinity::GetNoAffinityMask(),
EThreadCreateFlags  InCreateFlags = EThreadCreateFlags::None 
)
static

Factory method to create a thread with the specified stack size and thread priority.

参数
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
返回
The newly created thread or nullptr if it failed

◆ CreateInternal()

virtual bool FRunnableThread::CreateInternal ( FRunnable *  InRunnable,
const TCHAR *  InThreadName,
uint32  InStackSize = 0,
EThreadPriority  InThreadPri = TPri_Normal,
uint64  InThreadAffinityMask = 0,
EThreadCreateFlags  InCreateFlags = EThreadCreateFlags::None 
)
protectedpure virtual

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

参数
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
返回
True if the thread and all of its initialization was successful, false otherwise

◆ GetRunnableThread()

static FRunnableThread * FRunnableThread::GetRunnableThread ( )
inlinestaticprotected
返回
a runnable thread that is executing this runnable, if return value is nullptr, it means the running thread can be game thread or a thread created outside the runnable interface

◆ GetThreadID()

const uint32 FRunnableThread::GetThreadID ( ) const
inline

Thread ID for this thread

返回
ID that was set by CreateThread
参见
GetThreadName

◆ GetThreadName()

const FString & FRunnableThread::GetThreadName ( ) const
inline

Retrieves the given name of the thread

返回
Name that was set by CreateThread
参见
GetThreadID

◆ Kill()

virtual bool FRunnableThread::Kill ( bool  bShouldWait = true)
pure virtual

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.

参数
bShouldWaitIf true, the call will wait infinitely for the thread to exit.
返回
Always true

◆ SetThreadPriority()

virtual void FRunnableThread::SetThreadPriority ( EThreadPriority  NewPriority)
pure virtual

Changes the thread priority of the currently running thread

参数
NewPriorityThe thread priority to change to

◆ Suspend()

virtual void FRunnableThread::Suspend ( bool  bShouldPause = true)
pure virtual

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

参数
bShouldPauseWhether to pause the thread (true) or resume (false)

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