mx::mxThreadObject< Class, Parameter > Class Template Reference

Inheritance diagram for mx::mxThreadObject< Class, Parameter >:

mx::mxExec

List of all members.

Public Member Functions

 mxThreadObject (Class *ptr, int(Class::*f)(Parameter p))
void threadRun (Parameter p)
void threadStop ()
void threadWait ()
virtual int threadExec ()
const bool isRunning () const

Protected Attributes

bool running
int(Class::* func )(Parameter p)
Class * cls
SDL_Thread * thread_identifier
Parameter code_param


Detailed Description

template<typename Class, typename Parameter>
class mx::mxThreadObject< Class, Parameter >

Definition at line 88 of file mxthread.h.


Constructor & Destructor Documentation

template<typename Class , typename Parameter >
mx::mxThreadObject< Class, Parameter >::mxThreadObject ( Class *  ptr,
int(Class::*)(Parameter p)  f 
) [inline]

constructor

Definition at line 93 of file mxthread.h.

00094                 {
00095                         cls = ptr;
00096                         func = f;
00097                         thread_identifier = 0;
00098                 }


Member Function Documentation

template<typename Class , typename Parameter >
const bool mx::mxThreadObject< Class, Parameter >::isRunning (  )  const [inline]

isRunning is thread running?

Definition at line 115 of file mxthread.h.

00115 { return running; }

template<typename Class , typename Parameter >
int mx::mxThreadObject< Class, Parameter >::threadExec (  )  [inline, virtual]

threadExec

Implements mx::mxExec.

Definition at line 143 of file mxthread.h.

00144         {
00145 
00146                 if(cls == 0) return 0; // if for some reason you must delete the class that this
00147                                       //  function object points to make sure to set it to zero
00148                                      //  otherwise a segmentation fault will occour
00149                 int rt = (*cls.*func)(code_param);
00150                 running = false;
00151                 return rt;
00152         }

template<typename Class , typename Parameter >
void mx::mxThreadObject< Class, Parameter >::threadRun ( Parameter  p  )  [inline]

threadRun with Parameter

Parameters:
p paramter to pass to thread

Definition at line 134 of file mxthread.h.

00135         {
00136 
00137                 code_param = p;
00138                 running = true;
00139                 thread_identifier = SDL_CreateThread(thread_execute, (void*)this);
00140 
00141         }

template<typename Class , typename Parameter >
void mx::mxThreadObject< Class, Parameter >::threadStop (  )  [inline]

threadStop stop thread

Definition at line 160 of file mxthread.h.

00161         {
00162                 if(thread_identifier != 0)
00163                         SDL_KillThread(thread_identifier);
00164 
00165                 thread_identifier = 0;
00166         }

template<typename Class , typename Parameter >
void mx::mxThreadObject< Class, Parameter >::threadWait (  )  [inline]

threadWait wait for thread

Definition at line 154 of file mxthread.h.

00155         {
00156                 if(thread_identifier != 0)
00157                         SDL_WaitThread(thread_identifier, 0);
00158         }


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

Generated on Wed Jun 10 14:52:02 2009 for libmx by  doxygen 1.5.8