Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
684 B

#pragma once
class CCriticalSection
{
public:
CCriticalSection(CRITICAL_SECTION *pcs)
: _pcs(pcs)
{
// ASSERT(pcs);
}
HRESULT Lock()
{
HRESULT hr = S_OK;
__try {
::EnterCriticalSection(_pcs);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
hr = E_OUTOFMEMORY;
}
return hr;
}
HRESULT Unlock()
{
::LeaveCriticalSection(_pcs);
return S_OK;
}
private:
CRITICAL_SECTION *_pcs;
};