标签:
class CMutex { public: CMutex(const char *pName = NULL); //初始化锁 ~CMutex(); virtual bool Lock()=0; //锁操作,纯虚函数 virtual bool UnLock()=0; //解锁操作,纯虚函数 const char * getName(void) const { return mutex_name; } protected: char *mutex_name; //锁名字 };
class CCountingSem { public: typedef enum { kTimeout, kForever }Mode; CCountingSem(); //初始化信号量 ~CCountingSem(); virtual bool Get() = 0; //接收信号量 virtual bool Post(void) = 0; //发送信号量 };
class COperatingSystemFactory { public: static COperatingSystem *newOperatingSystem(); static CCountingSem *newCountingSem(unsigned int init=0); //参数是信号量的初始值,一般为0 static CMutex *newMutex(const char *pName=NULL); };
C++多线程框架-----Mutex互斥和Sem信号量
原文地址:http://www.cnblogs.com/ranjiewen/p/5734535.html