guard.h
来自「Socketlib: 一个轻量级的C++ 封装Socket C API 网络编程」· C头文件 代码 · 共 47 行
H
47 行
//**********************************************************************
//
// Copyright (C) 2005-2007 Zhang bao yuan(bolidezhang@gmail.com).
// All rights reserved.
//
// This copy of Socketlib is licensed to you under the terms described
// in the LICENSE.txt file included in this distribution.
//
//**********************************************************************
#pragma once
namespace SYNC
{
template <class TMutex>
class CGuard
{
private:
//= Prevent assignment and initialization.
// Disallow copying and assignment.
CGuard(const CGuard &);
void operator= (const CGuard &);
public:
CGuard(TMutex & mtx)
: m_mtx(mtx)
{
m_mtx.Lock();
};
CGuard(TMutex & mtx, DWORD nTimeOut)
: m_mtx(mtx)
{
m_mtx.Lock(nTimeOut);
};
~CGuard(void)
{
m_mtx.UnLock();
};
private:
TMutex &m_mtx;
};
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?