Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuThread.h

Go to the documentation of this file.
00001 /*      Modified March 2002
00002         By Christopher Steinbach
00003         Modified to make the threads detachable so that
00004         my program will stop crashing on my animations...
00005 */
00006 
00007 #ifndef _VUTHREAD_H_
00008 #define _VUTHREAD_H_
00009 
00010 #include "vuSimpleTypes.h"
00011 #include <stddef.h>
00012 
00013 /* \todo implement vuThread and vuMutex for windows.
00014 
00015    Just wrap to wxThread and wxMutex instead pThread ... This should provide
00016    platform independence...
00017    Therefore do not directly derive from wxThread, because we would have to include wxXXX.h
00018    headers in vuThread.h. This would not allow us to use this inside the Volume tree. Instead
00019    maybe hold a void* handle to a wxThread or a derived class having the virtual Entry()
00020    function implemented.
00021    If we would directly inherit from wxThread it would make things a lot easier (and cleaner)
00022    but we would be restricted to use in the GUI class of our implementation (like vuRaycast).
00023    Maybe also feasible... I don't know.
00024 
00025    Old comments (not useful in connection with the nice wxThread class):
00026 
00027    information on thread wrapper classes for windows
00028    http://www.codeguru.com/system/OOThreadWrapper.html
00029    http://www.codeproject.com/threads/cthread.asp?print=true
00030 
00031 win/unix distiction:
00032 #if defined(WIN32)
00033 #include <blah.h>
00034 #else
00035 #include <blub.h>
00036 #endif
00037 
00038 */
00039 
00040 class vuLock;
00041 
00048 class vuMutex
00049 {
00050         friend class vuLock;
00051  public:
00054   vuMutex();
00057   ~vuMutex();
00058 
00063   void lock();
00067   bool trylock();
00071   void unlock();
00072 
00073  private:
00074   void * mutex;
00075 };
00076 
00080 class vuLock {
00081 public:
00083         vuLock(vuMutex &m) : lmutex(&m) {
00084                 lmutex->lock();
00085         }
00087         ~vuLock() {
00088                 lmutex->unlock();
00089         }
00090 private:
00091         vuMutex *lmutex;
00092 };
00093 
00099 class vuThread
00100 {
00101  public:
00103   virtual ~vuThread() {};
00104 
00108   bool startThread(int whatsup, void* data=NULL);
00109 
00110 //  void* retStartThread (int whatsup);
00111 
00115   virtual void run(int whatsup, void* data) = 0;
00116 
00117 //  virtual void* retrun (int whatsup) {};
00118 
00119   void stopThread();
00120 
00121  protected:
00122 
00123  private:
00124 
00125 #ifdef WIN32
00126   friend void _kickoff(void *ptr);
00127 #else
00128   friend void* _kickoff(void *ptr);
00129 #endif
00130   //friend void* _ret_kickoff(void *ptr);
00131 
00135   vuMutex       m_WhatsupMutex;
00136 
00138   int           m_Whatsup;
00140   void*         m_AdditionalData;
00141 
00142 };
00143 
00144 
00145 vuMutex& getLogMut();
00146 
00147 #define MFDEBUGMSG(msg) do{ \
00148 }while(0);
00149 
00150 //vuLock l(getLogMut());
00151 //FDEBUGMSG(msg);
00152 
00153 #endif

Generated on Wed Dec 15 21:20:38 2004 for vuVolume by  doxygen 1.3.9.1