PThread Class Reference

pthread C++ wrapper More...

#include <pthread.h>

List of all members.

Public Member Functions

 PThread ()
 Constructor.
 ~PThread ()
 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
bool running
 running status
bool finished
 finished status


Detailed Description

pthread C++ wrapper

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

Definition at line 48 of file pthread.h.


Constructor & Destructor Documentation

PThread::PThread (  ) 

Constructor.

The class constructor. Initialize private attributes

Postcondition:
An object is contructed

Definition at line 37 of file pthread.cpp.

References finished, handle, and running.

PThread::~PThread (  ) 

Destructor.

The class destructor

Definition at line 46 of file pthread.cpp.

References handle, and terminate().


Member Function Documentation

bool PThread::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 pthread.cpp.

References threadParams::args, finished, threadParams::finished, handle, isRunning(), threadParams::process, running, threadParams::running, and threadStartup().

Referenced by RemoteControl::RemoteControl().

pthread_t * PThread::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 144 of file pthread.cpp.

References handle.

bool PThread::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 125 of file pthread.cpp.

References finished.

bool PThread::isRunning (  ) 

Check if the thread is running.

Give running state

Returns:
True if the thread is running, else false

Definition at line 115 of file pthread.cpp.

References running.

Referenced by exec(), and terminate().

void * PThread::join (  ) 

Join thread.

Wait for thread end, and then free memory

Definition at line 132 of file pthread.cpp.

References handle.

bool PThread::terminate (  ) 

Terminate (cancel) the thread.

Cancel the thread

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

Definition at line 100 of file pthread.cpp.

References handle, isRunning(), and running.

Referenced by ~PThread().

void * PThread::threadStartup ( void *  targs  )  [static, private]

threaded function

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

Postcondition:
running and finished flags are updated
Parameters:
targs thread arguments

Definition at line 81 of file pthread.cpp.

References threadParams::args, threadParams::finished, finished, threadParams::process, threadParams::running, and running.

Referenced by exec().


Member Data Documentation

bool PThread::finished [private]

finished status

Definition at line 56 of file pthread.h.

Referenced by exec(), isFinished(), PThread(), and threadStartup().

pthread_t* PThread::handle [private]

pthread handle

Definition at line 52 of file pthread.h.

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

bool PThread::running [private]

running status

Definition at line 54 of file pthread.h.

Referenced by exec(), isRunning(), PThread(), terminate(), and threadStartup().


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

Generated on Sun Apr 19 02:47:36 2009 for trustyRC by  doxygen 1.5.7.1