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

📄 safeobject.h

📁 vc环境下的pgp源码
💻 H
字号:
///////////////////////////////////////////////////////////////////////////////
// SafeObject.h
//
// Declaration and implementation of class SafeObject
///////////////////////////////////////////////////////////////////////////////

// Copyright (C) 1998 by Network Associates, Inc.
// All rights reserved.

#ifndef Included_SafeObject_h	// [
#define Included_SafeObject_h

#include "DualErr.h"
#include "WaitObjectClasses.h"


///////////////////
// Class SafeObject
///////////////////

// SafeObject is the base class for all thread-safe objects in the project.
// It provides a mutex and two functions for entering and leaving that
// mutex, intended to be placed around accesses to the object. Lock/Unlock
// fake 'constness' so that const member functions of derived classes can use
// them.

class SafeObject
{
public:
	DualErr mInitErr;

			SafeObject();

	void	Lock() const;				// claim object for use
	void	Unlock() const;				// release object

private:
	mutable PGPdiskMutex mAccessMutex;
};


/////////////////////////////////////////////////////////////
// Class SafeObject public inline member function definitions
/////////////////////////////////////////////////////////////

// The SafeObject constructor creates the mutex.

inline
SafeObject::SafeObject()
{
	mInitErr = mAccessMutex.mInitErr;
}

// Lock is called to lock the object for access by one thread.

inline 
void 
SafeObject::Lock() const
{
	mAccessMutex.Enter();
}

// Unlock releases a locked object.

inline 
void 
SafeObject::Unlock() const
{
	mAccessMutex.Leave();
}

#endif	// ] Included_SafeObject_h

⌨️ 快捷键说明

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