📄 lock.h
字号:
/********************************************************************
// Project: Evolution
//
// FileName: Lock.h
//
// Author:
//
// Created:
//
// Function: Lock & Mutex
//
// Remark:
//
*********************************************************************/
#ifndef _LOCK_H_
#define _LOCK_H_
#ifdef WIN32
#include <windows.h>
#else
#include <pthread.h>
#endif
class CMutex
{
friend class CLock;
public:
#ifdef WIN32
CMutex ()
{
InitializeCriticalSection (&_critSection);
}
~CMutex ()
{
DeleteCriticalSection (&_critSection);
}
void Acquire ()
{
EnterCriticalSection (&_critSection);
}
void Release ()
{
LeaveCriticalSection (&_critSection);
}
#else
CMutex ()
{
pthread_mutex_init(&_critSection, NULL);
}
~CMutex ()
{
pthread_mutex_destroy(&_critSection);
}
void Acquire ()
{
pthread_mutex_lock(&_critSection);
}
void Release ()
{
pthread_mutex_unlock(&_critSection);
}
#endif
private:
#ifdef WIN32
CRITICAL_SECTION _critSection;
#else
pthread_mutex_t _critSection;
#endif
};
#endif //_LOCK_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -