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:
|
2015-10-25 09:10:28 +00:00
|
|
|
CriticalSection();
|
|
|
|
~CriticalSection(void);
|
|
|
|
|
|
|
|
void enter(void);
|
|
|
|
void leave(void);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CriticalSection(const CriticalSection&); // Disable copy constructor
|
|
|
|
CriticalSection& operator=(const CriticalSection&); // Disable assignment
|
2015-10-25 09:10:28 +00:00
|
|
|
void * m_cs;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGuard
|
|
|
|
{
|
|
|
|
public:
|
2015-10-25 09:10:28 +00:00
|
|
|
CGuard(CriticalSection& sectionName) : m_cs(sectionName)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-10-25 09:10:28 +00:00
|
|
|
m_cs.enter();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
~CGuard()
|
|
|
|
{
|
2015-10-25 09:10:28 +00:00
|
|
|
m_cs.leave();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
private:
|
2015-10-25 09:10:28 +00:00
|
|
|
CriticalSection& m_cs;
|
2008-09-18 03:15:49 +00:00
|
|
|
CGuard(const CGuard& copy);
|
2009-12-28 22:22:50 +00:00
|
|
|
CGuard &operator=(const CGuard& rhs);
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|