Files
cefsharp/CefSharp.Core/Internals/AutoLock.h
T
amaitland ee50034502 Reorder/Include pragma once
Add license to AutoLock
This is more of a generic cleanup - no time like the present
2015-04-17 13:07:08 +10:00

62 lines
1.1 KiB
C++

// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#pragma once
#include <Windows.h>
namespace CefSharp
{
namespace Internals
{
private class CriticalSection
{
public:
CriticalSection()
{
::InitializeCriticalSection(&_cs);
}
~CriticalSection()
{
::DeleteCriticalSection(&_cs);
}
void Enter()
{
::EnterCriticalSection(&_cs);
}
void Leave()
{
::LeaveCriticalSection(&_cs);
}
private:
CriticalSection(const CriticalSection&);
CriticalSection& operator=(const CriticalSection&);
CRITICAL_SECTION _cs;
};
private class AutoLock
{
public:
AutoLock(CriticalSection& cs) : _cs(cs)
{
_cs.Enter();
}
~AutoLock()
{
_cs.Leave();
}
private:
AutoLock(const AutoLock&);
AutoLock& operator=(const AutoLock&);
CriticalSection& _cs;
};
};
};