mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
ee50034502
Add license to AutoLock This is more of a generic cleanup - no time like the present
62 lines
1.1 KiB
C++
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;
|
|
};
|
|
};
|
|
}; |