nCine::Thread class

Thread.

Public types

using ThreadFuncDelegate = void(*)(void*)

Public static functions

static void Sleep(std::uint32_t milliseconds)
Puts the current thread to sleep for the specified number of milliseconds.
static auto GetProcessorCount() -> std::uint32_t
Returns the number of processors in the machine.
static void SetCurrentName(const char* name)
Sets the calling thread name (not supported on Emscripten and Switch)
static auto GetCurrentId() -> std::uintptr_t
Returns the calling thread ID.
static void Exit()
Terminates the calling thread.
static void YieldExecution()
Yields the calling thread in favour of another one with the same priority.

Constructors, destructors, conversion operators

Thread()
A default constructor for an object without the associated function.
Thread(ThreadFuncDelegate threadFunc, void* threadArg)
Creates a thread around a function and runs it immediately.
~Thread()
Thread(const Thread& other)
Thread(Thread&& other) noexcept

Public functions

auto operator=(const Thread& other) -> Thread&
auto operator=(Thread&& other) -> Thread& noexcept
void Run(ThreadFuncDelegate threadFunc, void* threadArg)
Spawns a new thread if the object hasn't one already associated.
auto Join() -> bool
Joins the thread.
void Detach()
Detaches the running thread from the object.
void SetName(const char* name)
Sets the thread name (not supported on Apple, Emscripten and Switch)
auto GetPriority() const -> std::int32_t
Gets the thread priority.
void SetPriority(std::int32_t priority)
Sets the thread priority.
auto Abort() -> bool
Tries to cancel or terminate the thread (depending on operating system)
auto GetAffinityMask() const -> ThreadAffinityMask
Gets the thread affinity mask.
void SetAffinityMask(ThreadAffinityMask affinityMask)
Sets the thread affinity mask.