class
#include <nCine/Threading/Thread.h>
Thread 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()
- Default constructor.
- Thread(ThreadFuncDelegate threadFunc, void* threadArg) explicit
- Creates a thread around a function and runs it immediately.
-
template<class Fn, class ... Args, std::Thread(Fn&& fn, Args && ... args) explicit
enable_if_t<!std:: is_same<std:: remove_cv_t<std:: remove_reference_t<Fn>>, Thread>::value && !std:: is_convertible<std:: decay_t<Fn>, ThreadFuncDelegate>::value, int> = 0> - ~Thread()
- Thread(const Thread& other)
- Thread(Thread&& other) noexcept
- operator bool() const explicit
- Whether the thread is running.
Public functions
- auto operator=(const Thread& other) -> Thread&
- auto operator=(Thread&& other) -> Thread& noexcept
- 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.
Function documentation
template<class Fn, class ... Args, std:: enable_if_t<!std:: is_same<std:: remove_cv_t<std:: remove_reference_t<Fn>>, Thread>::value && !std:: is_convertible<std:: decay_t<Fn>, ThreadFuncDelegate>::value, int> = 0>
nCine:: Thread:: Thread(Fn&& fn,
Args && ... args) explicit
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.