csemaphoreimpdrvnt.h

来自「可以实现对邮件的加密解密以及签名」· C头文件 代码 · 共 76 行

H
76
字号
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: CSemaphoreImpDrvNT.h,v 1.3 2002/08/06 20:10:51 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_CSemaphoreImpDrvNT_h	// [
#define Included_CSemaphoreImpDrvNT_h

#include "pgpClassesConfig.h"
#include "CSemaphoreImp.h"

_USING_PGP

// Class CSemaphoreImpDrvNT

class CSemaphoreImpDrvNT : public CSemaphoreImp
{
	friend class CPFLImpFactoryDrvNT;

private:
	CSemaphoreImpDrvNT();

public:
	~CSemaphoreImpDrvNT();

	PGPUInt32	Wait(PGPInt32 msTimeout);
	void		Signal(PGPUInt32 count);

private:
	KSEMAPHORE	mSemaphore;
};


// Class CSemaphoreImpDrvNT member functions

inline 
CSemaphoreImpDrvNT::CSemaphoreImpDrvNT()
{
	KeInitializeSemaphore(&mSemaphore, 0, 10000);
}

inline 
CSemaphoreImpDrvNT::~CSemaphoreImpDrvNT()
{
}

inline 
PGPUInt32 
CSemaphoreImpDrvNT::Wait(PGPInt32 msTimeout)
{
	LARGE_INTEGER	wait	= RtlConvertLongToLargeInteger(0 - 
		static_cast<PGPInt32>(msTimeout * PFLConstants::kHundredNsPerMs));

	if (msTimeout == CMutex::InfiniteTimeout)
	{
		return KeWaitForSingleObject(&mSemaphore, Executive, KernelMode, 
			FALSE, NULL);
	}
	else
	{
		return KeWaitForSingleObject(&mSemaphore, Executive, KernelMode, 
			FALSE, &wait);
	}
}

inline 
void 
CSemaphoreImpDrvNT::Signal(PGPUInt32 count)
{
	KeReleaseSemaphore(&mSemaphore, 0, count, FALSE);
}

#endif	// ] Included_CSemaphoreImpDrvNT_h

⌨️ 快捷键说明

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