Ark Server API (ASA) - Wiki
|
#include <Thread.h>
Public Types | |
enum | EForkable { Forkable , NonForkable } |
Public Member Functions | |
FThread () | |
FThread (TCHAR const *ThreadName, TUniqueFunction< void()> &&ThreadFunction, uint32 StackSize=0, EThreadPriority ThreadPriority=TPri_Normal, FThreadAffinity ThreadAffinity=FThreadAffinity(), EForkable IsForkable=NonForkable) | |
FThread (TCHAR const *ThreadName, TUniqueFunction< void()> &&ThreadFunction, TUniqueFunction< void()> &&SingleThreadTickFunction, uint32 StackSize=0, EThreadPriority ThreadPriority=TPri_Normal, FThreadAffinity ThreadAffinity=FThreadAffinity(), EForkable IsForkable=NonForkable) | |
FThread (const FThread &)=delete | |
FThread & | operator= (const FThread &)=delete |
FThread (FThread &&)=default | |
FThread & | operator= (FThread &&Other) |
~FThread () | |
bool | IsJoinable () const |
void | Join () |
uint32 | GetThreadId () const |
Static Public Attributes | |
static constexpr uint32 | InvalidThreadId = ~uint32(0) |
Private Attributes | |
TSharedPtr< class FThreadImpl, ESPMode::ThreadSafe > | Impl |
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 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
|
inline |
FThread::FThread | ( | TCHAR const * | ThreadName, |
TUniqueFunction< void()> && | ThreadFunction, | ||
uint32 | StackSize = 0, | ||
EThreadPriority | ThreadPriority = TPri_Normal, | ||
FThreadAffinity | ThreadAffinity = FThreadAffinity(), | ||
EForkable | IsForkable = NonForkable ) |
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.
ThreadName | Name of the thread |
ThreadFunction | The function that will be executed by the newly created thread |
StackSize | The size of the stack to create. 0 means use the current thread's stack size |
ThreadPriority | Tells the thread whether it needs to adjust its priority or not. Defaults to normal priority |
ThreadAffinity | Tells the thread whether it needs to adjust its affinity or not. Defaults to no affinity |
IsForkable | Tells the thread whether it can be forked. Defaults to NonForkable |
FThread::FThread | ( | TCHAR const * | ThreadName, |
TUniqueFunction< void()> && | ThreadFunction, | ||
TUniqueFunction< void()> && | SingleThreadTickFunction, | ||
uint32 | StackSize = 0, | ||
EThreadPriority | ThreadPriority = TPri_Normal, | ||
FThreadAffinity | ThreadAffinity = FThreadAffinity(), | ||
EForkable | IsForkable = NonForkable ) |
|
default |
FThread::~FThread | ( | ) |
Destructor asserts if the instance is not joined or detached.
uint32 FThread::GetThreadId | ( | ) | const |
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.
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.
Move assignment operator. Asserts if the instance is joinable.
|
private |