All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::Thread Class Referenceabstract

Platform-independent threading. More...

#include <Radiant/Thread.hpp>

Inheritance diagram for Radiant::Thread:
Patterns::NotCopyable MultiWidgets::RenderThread Radiant::WatchDog Resonant::AudioFileHandler VideoDisplay::AVDecoder VideoDisplay::LibavDecoder

Public Types

typedef void * id_t
 Thread id type. More...
 

Public Member Functions

bool isRunning () const
 Check if the thread is running. More...
 
void run ()
 Starts the thread.
 
void setName (const QString &name)
 Set the thread name. More...
 
 Thread (const QString &name="Radiant::Thread")
 Construct a thread structure. More...
 
bool waitEnd (int timeoutms=0)
 Waits until thread is finished. More...
 
virtual ~Thread ()
 Destructor. More...
 

Static Public Member Functions

static id_t myThreadId ()
 The id of the calling thread. More...
 

Protected Member Functions

virtual void childLoop ()=0
 The actual contents of the thread. More...
 

Detailed Description

Platform-independent threading.

This class is used by inheriting it and overriding the virtual method childLoop().

Member Typedef Documentation

typedef void* Radiant::Thread::id_t

Thread id type.

On most systems this is some kind of integer value.

Constructor & Destructor Documentation

Radiant::Thread::Thread ( const QString &  name = "Radiant::Thread")

Construct a thread structure.

The thread is NOT activated by this method.

Parameters
namethread name
See Also
setName
virtual Radiant::Thread::~Thread ( )
virtual

Destructor.

The thread must be stopped before this method is

called. Thread cannot be terminated within the destructor, as the inheriting class that implements the virtual childLoop function does not exist any more (its destructor is called before this function).

Member Function Documentation

virtual void Radiant::Thread::childLoop ( )
protectedpure virtual

The actual contents of the thread.

You need to override this to add functionality to your software

bool Radiant::Thread::isRunning ( ) const

Check if the thread is running.

Returns
true if the thread is running.
static id_t Radiant::Thread::myThreadId ( )
static

The id of the calling thread.

Returns
Id of the calling thread
void Radiant::Thread::setName ( const QString &  name)

Set the thread name.

The thread name can be used by some debuggers, for example QtCreator. Useful for debugging purposes. Does not affect any functionality.

Parameters
namethread name
bool Radiant::Thread::waitEnd ( int  timeoutms = 0)

Waits until thread is finished.

This method does nothing to kill the thread, it simply waits until the thread has run its course.

Parameters
timeoutmsHow many milliseconds this function call will block at most
Returns
true if the thread has terminated within the timeout period