CPPThread Class Reference

pthread C++ wrapper More...

#include <cppthread.h>

List of all members.

Public Member Functions

 CPPThread ()
 Constructor.
 ~CPPThread ()
 Destructor.
bool exec (threadProcess, void *)
 Prepare and launch a thread.
bool terminate ()
 Terminate (cancel) the thread.
bool isRunning ()
 Check if the thread is running.
bool isFinished ()
 Check if the thread is finished.
void * join ()
 Join thread.
pthread_t * getHandle ()
 Get thread's handle.

Static Private Member Functions

static void * threadStartup (void *)
 threaded function

Private Attributes

pthread_t * handle
 pthread handle
threadInfos ti
 Threads informations.


Detailed Description

pthread C++ wrapper

This class stores pthread management function to use a pthread as an object

Definition at line 48 of file cppthread.h.


Constructor & Destructor Documentation

CPPThread::CPPThread (  ) 

Constructor.

The class constructor. Initialize private attributes

Postcondition:
An object is contructed

Definition at line 37 of file cppthread.cpp.

References threadInfos::finished, handle, threadInfos::running, and ti.

CPPThread::~CPPThread (  ) 

Destructor.

The class destructor

Definition at line 46 of file cppthread.cpp.

References handle, and terminate().


Member Function Documentation

bool CPPThread::exec ( threadProcess  myThreadProcess,
void *  args 
)

Prepare and launch a thread.

Prepare and launch a thread. Stores a function to execute, and arguments, then create a thread, and launch the threadStartup

Parameters:
myThreadProcess Function to execute
args Arguments to send to the threaded function
Returns:
true if the thread has been launched, else false

Definition at line 60 of file cppthread.cpp.

References threadInfos::args, handle, isRunning(), threadInfos::process, threadStartup(), and ti.

Referenced by BotKernel::executeFunction(), and RemoteControl::RemoteControl().

pthread_t * CPPThread::getHandle (  ) 

Get thread's handle.

Return pthread handle. Use this handle to use pthread functions not provided by this class

Returns:
Handle's pointer

Definition at line 137 of file cppthread.cpp.

References handle.

bool CPPThread::isFinished (  ) 

Check if the thread is finished.

Tell if the thread is finished. The thread is concidered has finished if the exectuion has finished itself (not canceled)

Returns:
True if the thread is finished, else false

Definition at line 118 of file cppthread.cpp.

References threadInfos::finished, and ti.

bool CPPThread::isRunning (  ) 

Check if the thread is running.

Give running state

Returns:
True if the thread is running, else false

Definition at line 108 of file cppthread.cpp.

References threadInfos::running, and ti.

Referenced by exec(), and terminate().

void * CPPThread::join (  ) 

Join thread.

Wait for thread end, and then free memory

Definition at line 125 of file cppthread.cpp.

References handle.

Referenced by BotKernel::executeFunction().

bool CPPThread::terminate (  ) 

Terminate (cancel) the thread.

Cancel the thread

Returns:
true if the thread has been canceled, else false

Definition at line 93 of file cppthread.cpp.

References handle, isRunning(), threadInfos::running, and ti.

Referenced by BotKernel::executeFunction(), and ~CPPThread().

void * CPPThread::threadStartup ( void *  arg  )  [static, private]

threaded function

Threaded function. In this function, the thread is prepared, then the function to execute is launched.

Parameters:
arg thread information structure pointer
Postcondition:
running and finished flags are updated

Definition at line 78 of file cppthread.cpp.

References threadInfos::args, threadInfos::finished, threadInfos::process, threadInfos::running, and ti.

Referenced by exec().


Member Data Documentation

pthread_t* CPPThread::handle [private]

pthread handle

Definition at line 52 of file cppthread.h.

Referenced by CPPThread(), exec(), getHandle(), join(), terminate(), and ~CPPThread().

Threads informations.

Definition at line 56 of file cppthread.h.

Referenced by CPPThread(), exec(), isFinished(), isRunning(), terminate(), and threadStartup().


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

Generated on Sun Aug 16 15:28:36 2009 for trustyRC by  doxygen 1.5.8