$search
00001 // 00002 // MutexClass.h: header file 00003 // 00004 // Copyright (C) Walter E. Capers. All rights reserved 00005 // 00006 // This source is free to use as you like. If you make 00007 // any changes please keep me in the loop. Email them to 00008 // walt.capers@comcast.net. 00009 // 00010 // PURPOSE: 00011 // 00012 // To implement mutexes as a C++ object 00013 // 00014 // REVISIONS 00015 // ======================================================= 00016 // Date: 10.25.07 00017 // Name: Walter E. Capers 00018 // Description: File creation 00019 // 00020 // Date: 00021 // Name: 00022 // Description: 00023 // 00024 // 00025 00026 #ifndef MUTEX_CLASS 00027 #define MUTEX_CLASS 00028 00029 #ifndef WINDOWS 00030 #if defined(WIN32) || defined(WIN64) 00031 #define WINDOWS 00032 #endif 00033 #endif 00034 00035 #ifndef WINDOWS 00036 #include <pthread.h> 00037 #endif 00038 #include <blort/ThreadObject/Thread.h> 00039 00040 class CMutexClass 00041 { 00042 private: 00043 #ifdef WINDOWS 00044 HANDLE m_mutex; 00045 #else 00046 pthread_mutex_t m_mutex; 00047 #endif 00048 ThreadId_t m_owner; 00049 public: 00050 BOOL m_bCreated; 00051 void Lock(); 00052 void Unlock(); 00053 void Wait(); 00054 CMutexClass(void); 00055 ~CMutexClass(void); 00056 }; 00057 #endif 00058