#include "stdafx.h" #include "Lock.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CLock::CLock() { InitializeCriticalSection(&cs); } CLock::~CLock() { DeleteCriticalSection(&cs); } void CLock::lock() { EnterCriticalSection(&cs); } void CLock::unlock() { LeaveCriticalSection(&cs); } CAutoLock::CAutoLock(CLock* plock) { if(plock == NULL) return; m_plock = plock; m_plock->lock(); } CAutoLock::~CAutoLock() { m_plock->unlock(); m_plock = NULL; }