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

📄 lockable.hh

📁 It s a tool designed to extract as much information as possible from Bluetooth devices without the r
💻 HH
字号:
/* Copyright (C) 2005, SWECO, All Rights Reserved.   Definition of the lockable property of a class   $Id$   Author: Zsolt Molnar (Zsolt.Molnar@ieee.org)   ---------------------------------------------------------------------------*/#ifndef __LOCKABLE_HH__#define __LOCKABLE_HH__#include <pthread.h>#include <errno.h>#include "base.hh"#ifdef _cplusplusextern "C" {#endifclass Lockable {protected:	Lockable() {pthread_mutex_init(&_mutex, NULL);};	~Lockable() {pthread_mutex_destroy(&_mutex);};public:		void lock() {pthread_mutex_lock(&_mutex);};	void unlock() {pthread_mutex_unlock(&_mutex);};;	bool isLocked();	private:	pthread_mutex_t _mutex;};inline boolLockable::isLocked(){	int res = pthread_mutex_trylock(&_mutex);	if (res == EBUSY) {		return true;	} else {		pthread_mutex_unlock(&_mutex);	}	return false;	}#ifdef _cplusplus}#endif#endif // #ifndef __LOCKABLE_HH__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -