mirror of https://github.com/tongzx/nt5src
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.
40 lines
608 B
40 lines
608 B
#pragma once
|
|
|
|
//
|
|
// This is a generic class that wraps a given CComAutoCriticalSection
|
|
//
|
|
class CScopeCriticalSection
|
|
{
|
|
|
|
private:
|
|
CComAutoCriticalSection* m_pCriticalSection;
|
|
|
|
public:
|
|
CScopeCriticalSection(CComAutoCriticalSection* pNewCS) :
|
|
m_pCriticalSection(pNewCS)
|
|
{
|
|
Lock();
|
|
}
|
|
|
|
~CScopeCriticalSection()
|
|
{
|
|
Unlock();
|
|
}
|
|
|
|
void
|
|
inline Lock()
|
|
{
|
|
m_pCriticalSection->Lock();
|
|
}
|
|
|
|
|
|
void
|
|
inline Unlock()
|
|
{
|
|
m_pCriticalSection->Unlock();
|
|
}
|
|
|
|
};
|
|
|
|
|
|
#define ENTER_AUTO_CS CScopeCriticalSection _ScopeAutoCriticalSection(&m_AutoCS);
|