#include <win32thread.h>
Win32 implementation of thread class.
- Copyright
- (C) 2006 Radon Labs GmbH (C) 2013-2020 Individual contributors, see AUTHORS file
Inherits Core::RefCounted.
|
virtual void | EmitWakeupSignal () |
| override this method if your thread loop needs a wakeup call before stopping
|
|
virtual void | DoWork () |
| this method runs in the thread context
|
|
bool | ThreadStopRequested () const |
| check if stop is requested, call from DoWork() to see if the thread proc should quit
|
|
virtual | ~RefCounted () |
| destructor (called when refcount reaches zero)
|
|
|
static DWORD WINAPI | ThreadProc (LPVOID self) |
| internal thread proc helper function
|
|
◆ Priority
thread priorities
Enumerator |
---|
Low | |
Normal | |
High | |
◆ Win32Thread()
Win32::Win32Thread::Win32Thread |
( |
| ) |
|
◆ ~Win32Thread()
Win32::Win32Thread::~Win32Thread |
( |
| ) |
|
|
virtual |
◆ __DeclareClass()
◆ DoWork()
void Win32::Win32Thread::DoWork |
( |
| ) |
|
|
protectedvirtual |
this method runs in the thread context
This method should be derived in a Thread subclass and contains the actual code which is run in the thread.
The method must not call C-Lib functions under Win32. To terminate the thread, just return from this function. If DoWork() runs in an infinite loop, call ThreadStopRequested() to check whether the Thread object wants the thread code to quit.
◆ EmitWakeupSignal()
void Win32::Win32Thread::EmitWakeupSignal |
( |
| ) |
|
|
protectedvirtual |
override this method if your thread loop needs a wakeup call before stopping
This method is called by Thread::Stop() after setting the stopRequest event and before waiting for the thread to stop.
If your thread runs a loop and waits for jobs it may need an extra wakeup signal to stop waiting and check for the ThreadStopRequested() event. In this case, override this method and signal your event object.
◆ GetMyThreadId()
get the thread ID of this thread
Static method which returns the ThreadId of this thread.
◆ GetMyThreadName()
const char * Win32::Win32Thread::GetMyThreadName |
( |
| ) |
|
|
static |
obtain name of thread from within thread context
Static method to obtain the current thread name from anywhere in the thread's code.
◆ GetName()
get thread name
Get the thread's name.
This is the vanilla method which returns the name member. To obtain the current thread's name from anywhere in the thread's execution context, call the static method Thread::GetMyThreadName().
◆ GetPriority()
◆ GetStackSize()
SizeT Win32::Win32Thread::GetStackSize |
( |
| ) |
const |
|
inline |
◆ GetThreadAffinity()
uint Win32::Win32Thread::GetThreadAffinity |
( |
| ) |
|
|
inline |
◆ IsRunning()
bool Win32::Win32Thread::IsRunning |
( |
| ) |
const |
return true if thread has been started
Returns true if the thread is currently running.
◆ SetMyThreadName()
void Win32::Win32Thread::SetMyThreadName |
( |
const char * | n | ) |
|
|
static |
set thread name from within thread context
Static method which sets the name of this thread.
This is called from within ThreadProc. The string pointed to must remain valid until the thread is terminated!
◆ SetName()
set thread name
Set the thread's name.
To obtain the current thread's name from anywhere in the thread's execution context, call the static method Thread::GetMyThreadName().
◆ SetPriority()
void Win32::Win32Thread::SetPriority |
( |
Priority | p | ) |
|
|
inline |
◆ SetStackSize()
void Win32::Win32Thread::SetStackSize |
( |
SizeT | s | ) |
|
|
inline |
set stack size in bytes (default is 4 KByte)
◆ SetThreadAffinity()
void Win32::Win32Thread::SetThreadAffinity |
( |
const uint | mask | ) |
|
|
inline |
◆ Start()
void Win32::Win32Thread::Start |
( |
| ) |
|
start executing the thread code, returns when thread has actually started
Start the thread, this creates a Win32 thread and calls the static ThreadProc, which in turn calls the virtual DoWork() class of this object.
The method waits for the thread to start and then returns.
◆ Stop()
void Win32::Win32Thread::Stop |
( |
| ) |
|
request threading code to stop, returns when thread has actually finished
This stops the thread by signalling the stopRequestEvent and waits for the thread to actually quit.
If the thread code runs in a loop it should use the IsStopRequested() method to see if the thread object wants it to shutdown. If so DoWork() should simply return.
◆ ThreadProc()
DWORD WINAPI Win32::Win32Thread::ThreadProc |
( |
LPVOID | self | ) |
|
|
staticprivate |
internal thread proc helper function
Internal static helper method.
This is called by CreateThread() and simply calls the virtual DoWork() method on the thread object.
◆ ThreadStopRequested()
bool Win32::Win32Thread::ThreadStopRequested |
( |
| ) |
const |
|
inlineprotected |
check if stop is requested, call from DoWork() to see if the thread proc should quit
If the derived DoWork() method is running in a loop it must regularly check if the process wants the thread to terminate by calling ThreadStopRequested() and simply return if the result is true.
This will cause the thread to shut down.
◆ YieldThread()
void Win32::Win32Thread::YieldThread |
( |
| ) |
|
|
static |
yield the thread (gives up current time slice)
The yield function is empty on Win32 and Xbox360.
◆ affinityMask
uint Win32::Win32Thread::affinityMask |
|
private |
◆ name
◆ priority
◆ stackSize
SizeT Win32::Win32Thread::stackSize |
|
private |
◆ stopRequestEvent
◆ threadHandle
HANDLE Win32::Win32Thread::threadHandle |
|
private |
◆ ThreadName
ThreadLocal const char * Win32::Win32Thread::ThreadName = 0 |
|
staticprivate |
◆ threadStartedEvent
The documentation for this class was generated from the following files: