⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysemaphore.h

📁 socket 编程实例 singleServerMultipleClientSrc
💻 H
字号:
#ifndef mySemaphore_H
#define mySemaphore_H

#define OPEN 0
#define CREATE 1

#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <winuser.h>
#include <winbase.h>
#include <string>
using namespace std;

class mySemaphore
{

public:

    mySemaphore(string& sName=string(""),
		        long initialCount=0,long maxCount=1,
				int accessMode=CREATE,BOOL canInherit=TRUE);

    virtual ~mySemaphore();

public:

    void closeSemaphore();    
	BOOL lock(BOOL wait=TRUE);
    void unlock();

public:

	string& getSemaphoreName() { return semaphoreName; }
	long    getInitialCount()  { return initCount; }
    long    getMaxCount()      { return maxCount; }
	BOOL    getInerit()        { return inherit; }
	
private:

	void getErrorDetail(int&,string&);

private:

	long initCount;   // initialCount 
	long maxCount;    // max count
    BOOL inherit;     // can be inherited by child

    string semaphoreName;
    HANDLE semaphore;
    LPSECURITY_ATTRIBUTES sa;
};
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -