⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lock.h

📁 该模块基于USB FX2开发板
💻 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 + -