在window和linux上通用的SprtLock类头实现文件
/**
@file SprtLock.cpp
@brief Sprt锁操作类,SprtLock类实现
@author cxw
@version 版本编号:1.0 日期:2013-10-28 修订者:Long 修订内容:按照《C++编码规范》修改源文件
*/
#include "stdafx.h"
#include "SprtLock.h"
SprtLock::SprtLock(void)
{
createLock = false;
InitialLock();
}
SprtLock::~SprtLock()
{
#ifdef WIN32
CloseHandle(m_hMutex);
#else
pthread_mutex_destroy(&m_lock);
#endif
}
void SprtLock::InitialLock()
{
if (!createLock)
{
#ifdef WIN32
m_hMutex = CreateMutex(NULL,FALSE,NULL);
#else
pthread_mutex_init(&m_lock,NULL);
#endif
createLock = true;
}
}
int SprtLock::Lock()
{
//return WaitForSingleObject(this->m_lock,INFINITE);
#ifdef WIN32
return WaitForSingleObject(m_hMutex,INFINITE);
#else
return pthread_mutex_lock(&m_lock);
#endif
}
int SprtLock::Unlock()
{
//return SetEvent(this->m_lock);
#ifdef WIN32
return ReleaseMutex(m_hMutex);
#else
return pthread_mutex_unlock(&m_lock);
#endif
}
//void SprtLock::InitialWaite()
//{
// this->m_wait = CreateEvent(NULL, TRUE, FALSE, NULL);
//
//}
//
//int SprtLock::WaitProc()
//{
// if (WaitForSingleObject(this->m_wait, 0) == WAIT_OBJECT_0) // 这个KillClient在主线程里创建,用于控制线程退出
// {
// return Successful
// }
// else
// {
// return Failed
// }
//}
//
//int SprtLock::UnWait()
//{
// return SetEvent(this->m_wait);
//}
转载于:https://blog.51cto.com/tianyake/1568779
在window和linux上通用的SprtLock类头实现文件相关推荐
- linux系统读取excel文件是否存在,小弟我用poi读excel,在window下没有有关问题,但把程序放到linux上时,读取客户端的excel文件报错,不...
我用poi读excel,在window下没有问题,但把程序放到linux上时,读取客户端的excel文件报错,不知道如何解决 我用poi读excel,在window下没有问题,但把程序放到linux上 ...
- window文件转换到linux,Window和Linux上的文件相互转换
当前位置:我的异常网» Linux/Unix » Window和Linux上的文件相互转换 Window和Linux上的文件相互转换 www.myexceptions.net 网友分享于:2013- ...
- sql数据库备份默认路径_在Linux上SQL Server中更改默认数据库文件和备份路径
sql数据库备份默认路径 In a previous article, we explored the process to change default SQL dump file location ...
- 如何在Linux上找到包含特定文本的所有文件?
我正在尝试找到一种方法来扫描整个Linux系统,查找包含特定文本字符串的所有文件. 只是为了澄清,我在文件中寻找文本,而不是文件名. 当我查找如何做到这一点时,我遇到了两次这个解决方案: find / ...
- 【转】matlab与C/C++混合编程——在Windows/Linux上调用Matlab编译的动态库文件
转自:matlab与C/C++混合编程--在Windows/Linux上调用Matlab编译的动态库文件_sinat_18131557的博客-CSDN博客 date version comments ...
- linux上使用FTP下载远程PTF远程文件
linux上使用FTP下载远程PTF远程文件 #从FTP上下载单文件到本地 #!/bin/sh mkdir /market/datacopy/222/hanguang/scada/$(date +%Y ...
- Linux上搭建h2引擎加载h2文件
问题背景 因为排查canal问题,需要打开linux上部署的canal的对应的h2.mv.db文件 查了一下,原来h2官方就有这种引擎,可以加载对应的h2文件,实际上就canal的lib目录下有对 ...
- Debian8 Linux上安装SSH服务器并配置sshd_config文件启用root ssh登录
Debian Linux上安装SSH服务器 安装SSH服务器debian Linux允许我们通过ssh协议登录debian服务器.SSH是从远程位置登录debian的首选方法,因为ssh协议通过Int ...
- 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置
转储sql文件 In this article, we will talk about SQL Dump files and the process to change the dump direct ...
最新文章
- 某程序员leader吐槽自己的工作就是合并周报!撕逼扯淡!跪舔领导!月薪五万却非常焦虑!...
- 【PTA 天梯赛】L2-1 分而治之(结构体存边)
- linux上热编译react,如何使用react进行热加载
- 为Android Studio 项目手动下载gradle
- java截取utf8字符串_java中常用的字符串的截取方法
- html不建议翻译,[译] 可用但最不常见的 HTML5 标签
- 求整数数组的最小值c语言,编程实现求一个整数数组num[]中的最大值与最小值并输出结果的程序...
- 为什么烂软件大行其道而好软件无人问津?
- linux下RRDTool安装方法
- 设计原则Python
- 定能解决No instances available for provider
- MYSQL排序加分页报错Out of sort memory, consider increasing server sort buffer size
- URP实现毛玻璃效果一
- WordPress如何设置先登录再进入主页
- 新买的联想笔记本计算机选项,怎么我的计算机一开机全部都是雪花
- gmap mysql cachet_MySQL中binlog cache使用流程解惑
- 关于802.11ax
- 分享30个分类目录网站,seo优化首选,免费提交收录
- 在成长的路上,我们必须与自己坦诚相见
- 华丽丽的旋转彩带效果