mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 02:44:13 +08:00
29 lines
410 B
C++
29 lines
410 B
C++
#pragma once
|
|
|
|
class CTemporaryCS
|
|
{
|
|
public:
|
|
CTemporaryCS(CRITICAL_SECTION *cs)
|
|
{
|
|
EnterCriticalSection(cs);
|
|
m_cs = cs;
|
|
}
|
|
~CTemporaryCS()
|
|
{
|
|
LeaveCS();
|
|
}
|
|
void LeaveCS()
|
|
{
|
|
if (NULL!=m_cs)
|
|
LeaveCriticalSection(m_cs);
|
|
m_cs = NULL;
|
|
}
|
|
void EnterCS(CRITICAL_SECTION *cs)
|
|
{
|
|
LeaveCS();
|
|
EnterCriticalSection(cs);
|
|
m_cs = cs;
|
|
}
|
|
protected:
|
|
CRITICAL_SECTION *m_cs;
|
|
}; |