17 m_ShouldTerminate(false),
18 m_ThreadName(
std::move(a_ThreadName))
78 catch (
const std::exception & Oops)
96 #if defined(_MSC_VER) && !defined(NDEBUG)
106 #pragma pack(push, 8)
107 struct THREADNAME_INFO
116 const DWORD NAME_EXCEPTION = 0x406D1388;
117 const THREADNAME_INFO Name = { 0x1000,
m_ThreadName.c_str(),
static_cast<DWORD
>(-1), 0 };
121 RaiseException(NAME_EXCEPTION, 0,
sizeof(Name) /
sizeof(ULONG_PTR),
reinterpret_cast<const ULONG_PTR *
>(&Name));
123 __except (EXCEPTION_EXECUTE_HANDLER)
void LOGERROR(std::string_view a_Format, const Args &... args)
void Wait(void)
Waits until the event has been set.
void Set(void)
Sets the event - releases one thread that has been waiting in Wait().
std::atomic< bool > m_ShouldTerminate
The overriden Execute() method should check this value periodically and terminate if this is true.
cIsThread(AString &&a_ThreadName)
void Stop(void)
Signals the thread to terminate and waits until it's finished.
void Entrypoint(void)
This is the main thread entrypoint.
AString m_ThreadName
The name of the thread, used to aid debugging in IDEs which support named threads.
std::thread m_Thread
The thread object which holds the created thread for later manipulation.
cEvent m_Initialisation
The event that is used to wait with the thread's execution until the thread object is fully initializ...
void Start(void)
Starts the thread; returns without waiting for the actual start.
virtual void Execute(void)=0
This function, overloaded by the descendants, is called in the new thread.
void SetThreadName() const
Sets the name of the current thread to be the name provided in m_ThreadName.