project64/Source/Common/CriticalSection.h

37 lines
607 B
C
Raw Normal View History

#pragma once
class CriticalSection
{
public:
2022-10-03 08:04:42 +00:00
CriticalSection();
~CriticalSection(void);
2022-10-03 08:04:42 +00:00
void enter(void);
void leave(void);
private:
2022-10-03 08:04:42 +00:00
CriticalSection(const CriticalSection &);
CriticalSection & operator=(const CriticalSection &);
2022-10-03 08:04:42 +00:00
void * m_cs;
};
class CGuard
{
public:
2022-10-03 08:04:42 +00:00
CGuard(CriticalSection & sectionName) :
m_cs(sectionName)
{
m_cs.enter();
}
~CGuard()
{
m_cs.leave();
}
private:
2022-10-03 08:04:42 +00:00
CriticalSection & m_cs;
CGuard(const CGuard & copy);
CGuard & operator=(const CGuard & rhs);
};