ThreadUtilities.h

Go to the documentation of this file.
00001 //
00002 //  ThreadUtilities.h -- cross-platform Thread Utilities
00003 //  See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00004 //
00005 
00006 #ifndef CSL_ThreadUtilities_H
00007 #define CSL_ThreadUtilities_H
00008 
00009 #include "CSL_Types.h"
00010 
00011 namespace csl {
00012 
00013 typedef void* (*ThreadFunc)(void*);     
00014 
00018 class Synch {
00019 public:
00020     Synch() { }                 
00021     virtual ~Synch() { }        
00022     static Synch* MakeSynch();  
00023 
00024     virtual int lock() = 0;
00025     virtual int unlock() = 0;
00026     virtual int condWait() = 0;
00027     virtual int condSignal() = 0;
00028 };
00029 
00033 class Thread {
00034 public:
00035     Thread() { }
00036     virtual ~Thread() { }
00037     static Thread* MakeThread();    
00038 
00039     virtual int createThread(ThreadFunc func, void * args) = 0;
00040     virtual int createRealtimeThread(ThreadFunc func, void * args) = 0;
00041 };
00042 
00043 #include <pthread.h>
00044 
00048 class SynchPthread : public Synch {
00049 public:
00050     SynchPthread();
00051     ~SynchPthread();
00052 
00053     pthread_mutex_t mMutex;
00054     pthread_cond_t mCond;
00055 
00056     int lock();
00057     int unlock();
00058     int condWait();
00059     int condSignal();
00060 
00061 };
00062 
00066 class ThreadPthread : public Thread {
00067 public:
00068     ThreadPthread();
00069     ~ThreadPthread();
00070 
00071     pthread_t mThread;
00072     pthread_attr_t mAttributes;
00073 
00074     int createThread(ThreadFunc func, void* args);  
00075     int createRealtimeThread(ThreadFunc func, void* args);  
00076 };
00077 
00078 }
00079 
00080 #endif
00081 

Generated on Fri Apr 6 20:18:14 2007 for CSL by  doxygen 1.4.5-20051010