sptk2 logo
SPTK Home Page

sptk::CThread Class Reference
[Thread Classes]

Base thread object. More...

#include <CThread.h>

Inheritance diagram for sptk::CThread:

sptk::CThreadPool sptk::CWorkerThread

List of all members.

Public Member Functions

 CThread (std::string name)
 Constructor.
virtual ~CThread ()
 Destructor.
void run ()
 Starts the already created thread.
virtual void threadFunction ()=0
 The thread function. Should be overwritten by the derived class.
void terminate ()
 Requests to terminate the thread.
bool terminated () const
 Returns true if the thread is terminated.
bool running () const
 Returns true if the thread is running.
uint64_t id () const
 Returns this thread OS id.
const std::string & name () const
 Returns the name of the thread.

Static Public Member Functions

static uint64_t contextThreadId ()
 Returns context thread OS id.
static void msleep (int msec)
 Pauses the thread.

Protected Member Functions

void createThread ()
 Creates a thread.
void joinThread ()
 Waits until thread joins.
void destroyThread ()
 Destroys the thread.
void runThread ()
 Executes the thread function.

Static Protected Member Functions

static void * threadStart (void *p)
 Internally starts a new thread.

Protected Attributes

bool m_terminated
 Flag: is the thread terminated?
std::string m_name
 Thread name.
uint64_t m_id
pthread_t m_thread
 Thread handle.


Detailed Description

Base thread object.

Should be used for deriving a user thread by overwriting threadFunction().


Constructor & Destructor Documentation

sptk::CThread::CThread ( std::string  name  ) 

Constructor.

Parameters:
name CString, name of the thread for future references.


Member Function Documentation

static void sptk::CThread::msleep ( int  msec  )  [static]

Pauses the thread.

Parameters:
msec int, pause time in milliseconds


The documentation for this class was generated from the following file:

Mon Mar 5 11:56:20 2012: SPTK 3.5.7