00001 //Exclusive Usage/Thread/Process class 00002 00003 /* 00004 Creates an Object that can allow single-thread access to another object. 00005 When a Thread wants access to an object it will call Obtain() to gain 00006 access, and call Release() when it has completed its operations. 00007 */ 00008 00009 class ExclusiveThread { 00010 private: 00011 PTR handle; 00012 public: 00013 uint32 Owner; 00014 ExclusiveThread() : Owner(0) { handle = NULL; } 00015 ~ExclusiveThread(); 00016 BOOL Obtain(BOOL wait = TRUE, BOOL updateOwner = TRUE); 00017 void Release(); 00018 }; 00019 00020 //was a non-portable class that used 'asm xchg x,y' to perform locking (slow) 00021 #define ExclusiveUsage ExclusiveThread 00022 00023 class ExclusiveProcess { 00024 private: 00025 PTR handle; 00026 public: 00027 ExclusiveProcess() { handle = NULL; } 00028 ~ExclusiveProcess(); 00029 BOOL Obtain(char *name); 00030 void Release(); 00031 };