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

📄 cmuteximpdrvnt.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
字号:
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

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

#ifndef Included_CMutexImpDrvNT_h	// [
#define Included_CMutexImpDrvNT_h

#include "pgpClassesConfig.h"
#include "CMutexImp.h"

_PGP_BEGIN

// Class CMutexImpDrvNT

class CMutexImpDrvNT : public CMutexImp
{
	friend class CPFLImpFactoryDrvNT;

private:
	CMutexImpDrvNT();

	PGPUInt32	Enter(PGPInt32 msTimeout);
	void		Leave();

private:
	FAST_MUTEX	mFastMutex;		// KMUTEXES suck, don't use them

	mutable PETHREAD	mOwnerThread;
	mutable PGPUInt16	mNumTimesClaimed;
};


// Class CMutexImpDrvNT member functions

inline 
CMutexImpDrvNT::CMutexImpDrvNT() : 
	mOwnerThread(NULL), mNumTimesClaimed(0)
{
	ExInitializeFastMutex(&mFastMutex);
}

inline 
PGPUInt32 
CMutexImpDrvNT::Enter(PGPInt32 msTimeout)
{
	pgpAssert(msTimeout == CMutex::InfiniteTimeout);

	PETHREAD	currentThread	= PsGetCurrentThread();

	if (!ExTryToAcquireFastMutex(&mFastMutex) && 
		(currentThread != mOwnerThread))
	{
		ExAcquireFastMutex(&mFastMutex);
	}

	mNumTimesClaimed++;
	mOwnerThread = currentThread;

	return 0;
}

inline 
void 
CMutexImpDrvNT::Leave()
{
	pgpAssert(mNumTimesClaimed > 0);
	pgpAssert(PsGetCurrentThread() == mOwnerThread);

	if (--mNumTimesClaimed == 0)
	{
		mOwnerThread = NULL;
		ExReleaseFastMutex(&mFastMutex);
	}
}

_PGP_END

#endif	// ] Included_CMutexImpDrvNT_h

⌨️ 快捷键说明

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