libProcTer::CThread Class Reference

#include <cthread.h>

List of all members.

Public Member Functions

 CThread ()
 Constructor. Does not start the thread.
virtual ~CThread ()
 Destructor. If the thread is running, it will be stopped.
bool start ()
bool stop ()
bool isRunning ()
void makeLowPriority ()
virtual void threadFunc ()=0

Static Public Member Functions

static void * run (void *arg)

Protected Attributes

bool m_Terminate

Detailed Description

CJP <>
A thread class. You can create extra threads by making derived classes from CThread, and instantiating them.

You'll probably find plenty of reading material on multithreaded programming on the internet.

The main advantage of this class over other multithreading APIs is that libProcTer uses it, so by using this class, you are 100% sure your threads are compatible with libProcTer threads. Also, it makes your multithreading code portable to all platforms supported by libProcTer.

If you still want to use another threading API: libProcter uses standard win32 threads on windows, and POSIX threads on all other platforms.

Constructor & Destructor Documentation

libProcTer::CThread::CThread (  ) 

Constructor. Does not start the thread.

virtual libProcTer::CThread::~CThread (  )  [virtual]

Destructor. If the thread is running, it will be stopped.

Member Function Documentation

bool libProcTer::CThread::isRunning (  ) 

true if the thread is running, false otherwise.

void libProcTer::CThread::makeLowPriority (  ) 

Assigns a low priority to the thread. This is only possible when the thread is running.

bool libProcTer::CThread::start (  ) 

Starts the thread. Returns false on failure.

bool libProcTer::CThread::stop (  ) 

Stops the thread. Returns false on failure. This function blocks until the thread finishes voluntarily.

virtual void libProcTer::CThread::threadFunc (  )  [pure virtual]

The main function of the thread. You should implement this method in your derived classes.

The thread stops when this function returns.

You can return whenever you want, but you should return as soon as m_Terminate becomes true. Therefore, your implementation of threadFunc should check the value of m_Terminate at regular intervals, and return as soon as it becomes true.

Member Data Documentation

Indicates whether the thread should stop. threadFunc() should check this value at regular intervals, and return when it becomes true.

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

Generated on Sun Aug 2 13:23:11 2009 for libprocter by  doxygen 1.5.8