Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Thread.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Thread_h_
00003 #define INCLUDED_Thread_h_
00004 
00005 #ifdef PLATFORM_APERIOS
00006 #  warning Thread class is not Aperios compatable
00007 #else
00008 
00009 #include <stddef.h>
00010 #include <map>
00011 
00012 namespace ThreadNS {
00013   class Lock {
00014   public:
00015     Lock();
00016     explicit Lock(const Lock& l, bool autolock=true) : my_id(l.my_id) { if(autolock) lock(); }
00017     //explicit Lock(int ident, bool autolock=true);
00018     ~Lock();
00019     void lock();
00020     bool trylock();
00021     void unlock();
00022     int getID() const { return my_id; }
00023   protected:
00024     static std::map<int,struct LockStorage*> ids;
00025     static bool issetup;
00026     static void setup();
00027     int my_id;
00028   };  
00029 } 
00030 
00031 //! description of Thread
00032 class Thread {
00033 public:
00034   typedef ThreadNS::Lock Lock;
00035   Thread();
00036   virtual ~Thread()=0;
00037   
00038   virtual void start();
00039   virtual void * run();
00040   virtual unsigned int runloop() { return -1U; }
00041   virtual void stop();
00042   virtual void kill();
00043   virtual void murder();
00044   virtual void * join();
00045   virtual bool isRunning() const { return running; }
00046   
00047 protected:
00048   virtual void testCancel();
00049   static void * launch(void * msg);
00050   static void handle_signal(int sig);
00051   static void handle_exit(void * th);
00052   
00053   struct Threadstorage_t * pt;
00054   bool running;
00055   void * returnValue;
00056 
00057 private:
00058   Thread(const Thread& r); //!< don't call
00059   Thread& operator=(const Thread& r); //!< don't call
00060 };
00061 
00062 #endif //Aperios check
00063 
00064 #endif
00065 
00066 /*! @file
00067 * @brief Describes the Thread class and its AutoThread templated subclass
00068 * @author ejt (Creator)
00069 *
00070 * $Author: ejt $
00071 * $Name: tekkotsu-2_4_1 $
00072 * $Revision: 1.4 $
00073 * $State: Exp $
00074 * $Date: 2005/08/01 23:17:59 $
00075 */
00076 

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:49 2005 by Doxygen 1.4.4