/**
 * \file      Lock.h
 * \version   $Id$
 * \author    $$$03公司
 *            $$$03公司@###.com
 * \date      2006-7-19  21:11:00
 * \brief     互斥锁
 * 
 *	      互斥锁
 */

#pragma once
#include <windows.h>

/**
 * \brief 简短描述
 * 
 * 详细描述
 * 
 */
class iLock{
public:
	virtual void  Lock() = 0;
	virtual void  Unlock() = 0;
};

/**
 * \brief 简短描述
 * 
 * 详细描述
 * 
 */
class CLock : public iLock
{
	CRITICAL_SECTION	m_section;
public:
	CLock(void);
	virtual ~CLock(void);
	void Lock();
	void Unlock();
};

/**
 * \brief 简短描述
 * 
 * 详细描述
 * 
 */
class CMyLock : public iLock
{
	long volatile m_iLockCount;
public:
	CMyLock(void);
	void Lock();
	void Unlock();
};

/**
 * \brief 简短描述
 * 
 * 详细描述
 * 
 */
class CSafeLock
{
	iLock* m_plock;
public:
	CSafeLock(iLock* plock)
	{
		m_plock = plock;
		m_plock->Lock();
	}

	~CSafeLock()
	{
		m_plock->Unlock();
	}
};