windows-nt/Source/XPSP1/NT/base/win32/fusion/installer/includes/lock.h

38 lines
684 B
C
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
#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;
};