Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#ifndef SimpleMutexH
|
||||
#define SimpleMutexH
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef INFINITE
|
||||
#define INFINITE 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
//////////////////////////////
|
||||
//
|
||||
// 信号量
|
||||
//
|
||||
class CSema
|
||||
{
|
||||
protected:
|
||||
bool m_bCreate;// 用来控制是否生成信号量,缺省情况下生成。
|
||||
HANDLE m_hSema;
|
||||
|
||||
public:
|
||||
CSema(const char *sName, unsigned int nInit, bool bCreate=true);
|
||||
~CSema();
|
||||
int ActP(DWORD dwTimeOut = INFINITE); // 等待状态
|
||||
void ActV(); // 非等待状态
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
// 互斥量
|
||||
//
|
||||
class CMutexLock
|
||||
{
|
||||
protected:
|
||||
CSema * m_psmMut;
|
||||
public:
|
||||
CMutexLock(bool bCreate=true);
|
||||
CMutexLock(CSema * pSema, DWORD dwTimeOut = INFINITE);
|
||||
~CMutexLock();
|
||||
};
|
||||
|
||||
#endif //SimpleMutexH
|
||||
Reference in New Issue
Block a user