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

📄 wzddata.cpp

📁 The programs and applications on this disk have been carefully tested, but are not guaranteed for
💻 CPP
字号:
// WzdData.cpp : implementation of the CWzdData class
//

#include "stdafx.h"
#include "WzdData.h"

/////////////////////////////////////////////////////////////////////////////
// CWzdData

IMPLEMENT_SERIAL( CWzdData, CObject, 0 )


CWzdData::CWzdData()
{
	m_nInt=0;
	m_fFloat=0.0f;
	m_dwWord=0;
}

BOOL CWzdData::GetData(int *pInt,float *pFloat,DWORD *pWord)
{
	// we lock here too so that we'll never read half written data
	CSingleLock slock(&m_mutex);

	if (slock.Lock(1000))  // timeout in milliseconds, default= INFINITE
	{
		// get values--can also be lists and arrays
		*pInt=m_nInt;
		*pFloat=m_fFloat;
		*pWord=m_dwWord;
		return TRUE;
	}
	return FALSE; // timed out!

	// unlocks on return or you can call slock.Unlock();
}

BOOL CWzdData::SetData(int nInt,float fFloat,DWORD dwWord)
{
	CSingleLock slock(&m_mutex); //or with CMultiLock can specify several m_mutex's
								 // for waiting on several data items

	if (slock.Lock(1000))  // timeout in milliseconds, default= INFINITE
	{
		// set values--can also be lists and arrays
		m_nInt=nInt;
		m_fFloat=fFloat;
		m_dwWord=dwWord;
		return TRUE;
	}
	return FALSE; // timed out!

	// unlocks on return or you can call slock.Unlock();
}

⌨️ 快捷键说明

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