Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

Thread.h

00001 /*
00002  * $Id: Thread.h,v 1.6 2003/06/20 16:40:21 mindstorm2600 Exp $
00003  */
00004 #ifndef ___THREAD_H__
00005 #define ___THREAD_H__
00006 
00007 #ifdef USE_GNUPTH
00008 #include<pth.h>
00009 #else
00010         #ifdef USE_SDL
00011                 #include<SDL.h>
00012                 #include "SDL_thread.h"
00013         #else
00014                 #include<pthread.h>
00015         #endif
00016 #endif
00017 #include<Object.h>
00018 #include<Threading.h>
00019 #include<Mutex.h>
00020 
00021 namespace clawsoft{
00026         class Thread:public Threading{
00027          private:
00029           bool _running;
00030         #ifdef GNU_PTH
00031 
00032           pth_t thread;
00036           static void *runMethod(void *thethread);
00037         #else
00038          #ifdef USE_SDL
00039 
00040           SDL_Thread *thread;
00044           static int runMethod(void *thethread);
00045          #else
00046 
00047           pthread_t thread;
00051           pthread_attr_t t_attr;
00055           static void *runMethod(void *thethread);
00056          #endif
00057         #endif
00058          protected:
00060           int _start();
00062           void detach();
00063           int policy;
00064          public:
00065           enum SchedPolicy{
00067                 NORMAL,
00069                 ROUND_ROBIN,
00071                 FIFO
00072           };
00077           bool autodetach;
00079           Thread();
00081           virtual ~Thread(){
00082                   detach();
00083           }
00085           int start();
00090           virtual void *run() = 0;
00094           void killMe();
00098           bool isRunning(){
00099             return _running;
00100           }
00107           void setSchedulingPolicy(SchedPolicy pol = NORMAL);
00108 
00113           void setPriority(int prio);
00114         };
00115 };
00116 
00117 #endif

Authors:

Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara

Powered by:

SourceForgeLogo