#include <linuxthread.h>
Linux implementation of Threading::Thread.
Uses the pthread API.
(C) 2010 Radon Labs GmbH (C) 2013-2018 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 void * | ThreadProc (void *) |
| Internal static helper method.
|
|
◆ Priority
thread priorities
Enumerator |
---|
Low | |
Normal | |
High | |
◆ ThreadState
thread states
Enumerator |
---|
Initial | |
Running | |
Stopped | |
◆ LinuxThread()
Linux::LinuxThread::LinuxThread |
( |
| ) |
|
◆ ~LinuxThread()
Linux::LinuxThread::~LinuxThread |
( |
| ) |
|
|
virtual |
◆ __DeclareClass()
◆ DoWork()
void Linux::LinuxThread::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 Linux::LinuxThread::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 * Linux::LinuxThread::GetMyThreadName |
( |
| ) |
|
|
static |
◆ GetMyThreadPriority()
int Linux::LinuxThread::GetMyThreadPriority |
( |
| ) |
|
|
static |
get the current actual thread-priority of this thread (platform specific!)
◆ GetMyThreadStopRequested()
bool Linux::LinuxThread::GetMyThreadStopRequested |
( |
| ) |
|
|
static |
get the stop-requested state of this thread (not yet implemented in Linux)
Static method which returns the stop-requested state of this thread.
Not yet implemented in Linux (see improvements to thread-local- data system under Linux in the Nebula mobile thread).
◆ GetName()
get thread name
Get the thread's name.
This is the vanilla method which returns the name member.
◆ GetPriority()
◆ GetStackSize()
SizeT Linux::LinuxThread::GetStackSize |
( |
| ) |
const |
|
inline |
◆ GetThreadAffinity()
uint Linux::LinuxThread::GetThreadAffinity |
( |
| ) |
|
◆ IsRunning()
bool Linux::LinuxThread::IsRunning |
( |
| ) |
const |
return true if thread has been started
Returns true if the thread is currently running.
◆ SetMaxStackSize()
void Linux::LinuxThread::SetMaxStackSize |
( |
SizeT | s | ) |
|
|
inline |
◆ SetMyThreadName()
void Linux::LinuxThread::SetMyThreadName |
( |
const Util::String & | n | ) |
|
|
staticprivate |
set thread name
Returns an array with infos about all currently existing thread objects.
◆ SetName()
set thread name
Set the thread's name.
◆ SetPriority()
void Linux::LinuxThread::SetPriority |
( |
Priority | p | ) |
|
|
inline |
◆ SetStackSize()
void Linux::LinuxThread::SetStackSize |
( |
SizeT | s | ) |
|
|
inline |
◆ SetThreadAffinity()
void Linux::LinuxThread::SetThreadAffinity |
( |
uint | mask | ) |
|
◆ Start()
void Linux::LinuxThread::Start |
( |
| ) |
|
start executing the thread code, returns when thread has actually started
◆ Stop()
void Linux::LinuxThread::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()
void * Linux::LinuxThread::ThreadProc |
( |
void * | self | ) |
|
|
staticprotected |
Internal static helper method.
This is called by pthread_create() and simply calls the virtual DoWork() method on the thread object.
◆ ThreadStopRequested()
bool Linux::LinuxThread::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 Linux::LinuxThread::YieldThread |
( |
| ) |
|
|
static |
yield the thread (gives up current time slice)
Give up time slice.
◆ affinity
cpu_set_t Linux::LinuxThread::affinity |
|
private |
◆ name
◆ priority
◆ stackSize
SizeT Linux::LinuxThread::stackSize |
|
private |
◆ stopRequestEvent
◆ thread
pthread_t Linux::LinuxThread::thread |
|
private |
◆ threadStartedEvent
◆ threadState
The documentation for this class was generated from the following files: