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

📄 myosmutex.cpp

📁 以下是研究 mysql 5.0.22 得出的结果,描述并使用标准 c++演示了使用 MySQLC API 函数 简单操作数据库的流程
💻 CPP
字号:

#include "myosmutex.h"

MyOSMutex::MyOSMutex()
{
#ifdef WIN32
	::InitializeCriticalSection(&fMutex);
#else
	(void)pthread_mutex_init(&fMutex,0);
#endif
}

MyOSMutex::~MyOSMutex()
{
	#ifdef WIN32
    ::DeleteCriticalSection(&fMutex);
#else
    pthread_mutex_destroy(&fMutex);
#endif
}

void  MyOSMutex::Lock()
{
	#ifdef WIN32
    ::EnterCriticalSection(&fMutex);
#else
    (void)pthread_mutex_lock(&fMutex);
#endif
}

void  MyOSMutex::Unlock()
{
	#ifdef WIN32
        ::LeaveCriticalSection(&fMutex);
#else
      pthread_mutex_unlock(&fMutex);
#endif
}

bool MyOSMutex::TryLock()
{
/*#ifdef WIN32
	// Return values of this function match our API
	//#define _WIN32_WINNT 0x0500
	if(::TryEnterCriticalSection(&fMutex) == 0)
	{
		return false;
	}
#else
	int theErr = pthread_mutex_trylock(&fMutex);
	if(theErr != 0)
	{
		assert(theErr == EBUSY);
		return false;
	}
#endif*/
	return true;
}

⌨️ 快捷键说明

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