Thread.h

Go to the documentation of this file.
00001 /* -*- Mode: CC; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00007 #ifndef _THREAD_
00008 #define _THREAD_
00009 
00010 #include <pthread.h>
00011 
00012 class Thread {
00013  protected:
00014      pthread_t thread;
00015      int retval;
00016      bool shouldStop;
00017      bool running;
00018      bool started;
00019      
00020  public:
00021      Thread() : thread(0), retval(0), shouldStop(false), 
00022           running(false), started(false) {}
00023      virtual ~Thread() {}
00024      virtual const int start();
00025      virtual const int join();
00026           
00027      inline const bool isRunning() const { return running; }
00028      inline const bool isStarted() const { return started; }
00029      inline const bool isDone() const { return (!running && started); }
00030      inline const int getReturnValue() const { return retval; }
00031      
00032  protected:     
00033      virtual void run()=0;
00034      
00035  private:
00036      static void* Start(void* obj);
00037 }; //class Thread
00038 
00039 #endif

Generated on Sun Mar 11 15:33:24 2007 for MetalWarriors by  doxygen 1.4.7