2008-09-18 03:15:49 +00:00
|
|
|
#pragma once
|
2015-10-25 09:10:28 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
class CriticalSection
|
|
|
|
{
|
|
|
|
public:
|
2022-10-03 08:04:42 +00:00
|
|
|
CriticalSection();
|
|
|
|
~CriticalSection(void);
|
2015-10-25 09:10:28 +00:00
|
|
|
|
2022-10-03 08:04:42 +00:00
|
|
|
void enter(void);
|
|
|
|
void leave(void);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
private:
|
2022-10-03 08:04:42 +00:00
|
|
|
CriticalSection(const CriticalSection &);
|
|
|
|
CriticalSection & operator=(const CriticalSection &);
|
2021-04-13 00:07:11 +00:00
|
|
|
|
2022-10-03 08:04:42 +00:00
|
|
|
void * m_cs;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGuard
|
|
|
|
{
|
|
|
|
public:
|
2022-10-03 08:04:42 +00:00
|
|
|
CGuard(CriticalSection & sectionName) :
|
|
|
|
m_cs(sectionName)
|
|
|
|
{
|
|
|
|
m_cs.enter();
|
|
|
|
}
|
|
|
|
~CGuard()
|
|
|
|
{
|
|
|
|
m_cs.leave();
|
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
private:
|
2022-10-03 08:04:42 +00:00
|
|
|
CriticalSection & m_cs;
|
|
|
|
CGuard(const CGuard & copy);
|
|
|
|
CGuard & operator=(const CGuard & rhs);
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|