本文整理汇总了C++中CMutex::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CMutex::Unlock方法的具体用法?C++ CMutex::Unlock怎么用?C++ CMutex::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMutex
的用法示例。
在下文中一共展示了CMutex::Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CNetRange *GetNetRange(list<CNetRange> &plNetRanges)
{ g_mScanner.Lock();
int iHighestScore=0; CNetRange *pNetRange=NULL;
for(list<CNetRange>::iterator in=plNetRanges.begin(); in!=plNetRanges.end(); in++)
{ int iScore=brandom(0, (*in).iPriority);
if(iScore > iHighestScore) { iHighestScore=iScore; pNetRange=&(*in); } }
g_mScanner.Unlock(); return pNetRange; }
示例2: sizeof
//////////////////////////////////////////////////////////////////////////
//
// Function Name: ViewFinderCallBackFun
// Description: The function which receives the picture from a camera
// Parameters: cdVoid *pBuf
// cdUInt32 Size
// cdUInt32 Format
// cdContext Context
// Returns: cdError code
// Summary:
// Author: CannonSDK
///////////////////////////////////////////////////////////////////////////
cdUInt32 cdSTDCALL CCameraConnect::ViewFinderCallBackFun( cdVoid *pBuf,
cdUInt32 Size,
cdUInt32 Format,
cdContext Context )
{
cdError err=cdOK;
LPBYTE bpPixel;
PBITMAPFILEHEADER pBmpFileheader;
PBITMAPINFOHEADER pBmpInfoheader;
CCameraConnect *CpThis;
CpThis = (CCameraConnect*)Context;
if( Format == FILEFORMAT_BMP )
{
pBmpFileheader = (PBITMAPFILEHEADER)pBuf;
pBmpInfoheader = (PBITMAPINFOHEADER)((LPBYTE)pBuf + sizeof(BITMAPFILEHEADER));
bpPixel = (LPBYTE)pBuf + pBmpFileheader->bfOffBits;
// A picture is saved at a buffer.
g_CVFMutex.Lock();
memcpy(CpThis->m_BackSurface.vpBits, bpPixel, pBmpInfoheader->biSizeImage );
g_CVFMutex.Unlock();
// A picture is displayed.
g_CpVFThread->ResumeThread();
}
return err;
}
示例3:
~CScopeLock()
{
if( is_nullable == false || _mutex )
{
_mutex->Unlock();
}
}
示例4: SetHeaderControlText
void LListCtrl::SetHeaderControlText( DWORD dwPos, const CUString& strValue )
{
myLockListCtrl.Lock();
if ( m_hWnd )
{
CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
ASSERT( (int)dwPos < pHeaderCtrl->GetItemCount() );
HDITEM hdi;
memset( &hdi, 0, sizeof( HDITEM ) );
// Get header item data
pHeaderCtrl->GetItem( dwPos, &hdi );
// modify item data
CUStringConvert strCnv;
hdi.pszText = strCnv.ToT( strValue );
hdi.mask = HDI_TEXT;
// Set item data
pHeaderCtrl->SetItem( dwPos, &hdi );
}
myLockListCtrl.Unlock();
}
示例5: CheckClock
void CTxWndDrawClockMgr::CheckClock( UINT nClockIn )
{
g_mutexDrawClock.Lock(1000);
MAPCLOCLKDATA::iterator itb = m_mapClockData.begin();
MAPCLOCLKDATA::iterator ite = m_mapClockData.end();
HWND hInvalidWnd = FALSE;
for (; itb != ite; itb++)
{
if (itb->second.nCurrentTick < nClockIn)
{
//send draw msg
if (::IsWindow(itb->first))
{
::PostMessage(itb->first, MSG_TXDRAWCLOCK, itb->second.wparam, itb->second.lparam);
itb->second.nCurrentTick = nClockIn + itb->second.nTickInternal;
}
else
{
//error;
hInvalidWnd = itb->first;
}
}
}
g_mutexDrawClock.Unlock();
if (hInvalidWnd != NULL)
{
ST_DRAWCLOCKDATA data;
data.hwnd = hInvalidWnd;
UnRegisterDrawClock(data);
}
}
示例6: setPreparedCallback
//设置一个回调函数,当数据准备好后,将数据回馈过去
void ZTDataBase::setPreparedCallback(DataProparedFunc *callbackFunc){
CMutex mutex;
mutex.Lock();
m_callbackfunc = callbackFunc;
mutex.Unlock();
}
示例7: GetHost
CString GetHost(CNetRange *pNetRange)
{ if(!pNetRange) return CString(""); CString sRetVal; g_mScanner.Lock(); switch(pNetRange->iNetMask) {
case 0: sRetVal.Format("%d.%d.%d.%d", brandom(0, 255), brandom(0, 255), brandom(0, 255), brandom(0, 255) ); break;
case 8: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, brandom(0, 255), brandom(0, 255), brandom(0, 255) ); break;
case 16: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, brandom(0, 255), brandom(0, 255) ); break;
case 24: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, pNetRange->iPart3, brandom(0, 255) ); break;
default:
case 32: sRetVal.Format("%d.%d.%d.%d", pNetRange->iPart1, pNetRange->iPart2, pNetRange->iPart3, pNetRange->iPart4 ); break; }
g_mScanner.Unlock(); return sRetVal; }
示例8: UnregisterClass
CCheckUSB::~CCheckUSB(){
if(ifInit == 1){
if(ifCheckIn == 1){
//变为不是1之后就开始退出消息检测循环
CMutex mutex;
mutex.Lock();
if(stateIn == 1) stateIn = 3;
mutex.Unlock();
//阻塞直到退出循环之后才可以执行释放动作
while(stateIn != 0);
//此时关闭之后句柄就已经无效了不需要再销毁
CloseWindow(Son->h_CheckIn);
if(IsWindow(Son->h_CheckIn) != 0) AfxMessageBox("未成功关闭");
//成功关闭窗口之后就可以反注册类了
BOOL nSucceed = UnregisterClass("USBIn",AfxGetInstanceHandle());
if(nSucceed == 0) AfxMessageBox("反注册类失败");
}
if(ifCheckOut == 1){
//变为不是1之后就开始退出消息检测循环
CMutex mutex;
mutex.Lock();
//如果在循环内则让他跳出循环
if(stateOut == 1) stateOut = 3;
mutex.Unlock();
//阻塞直到退出循环之后才可以执行释放动作
while(stateOut != 0);
//此时关闭之后句柄就已经无效了不需要再销毁
CloseWindow(Son->h_CheckOut);
if(IsWindow(Son->h_CheckOut) != 0) AfxMessageBox("未成功关闭");
//成功关闭窗口之后就可以反注册类了
BOOL nSucceed = UnregisterClass("USBOut",AfxGetInstanceHandle());
if(nSucceed == 0) AfxMessageBox("反注册类失败");
}
}
//在销毁之后就可以继续再产生CCheckUSB了,所以这里需要重置为0
ifInit = 0;
}
示例9: FlushFIFO
void ISndStreamWinAmp::FlushFIFO( )
{
// lock access to FIFO parameters
g_mFifoAcces.Lock();
g_nFifoFreeBuffers = WAPI_FIFO_NUM_BUFFERS;
g_nFifoReadIdx = 0;
g_nFifoWriteIdx = 0;
g_eFifoNotFull.SetEvent( );
g_eFifoNotEmpty.ResetEvent( );
g_nFifoTotalBytes = 0;
// unlock access to FIFO parameters
g_mFifoAcces.Unlock();
}
示例10: UnInit
void CFileUpLoad::UnInit()
{
m_bStop = TRUE;
m_bConnect = FALSE;
g_bFileConnect = false;
m_bUpLoad = FALSE;
g_pLogger->information("CFileUpLoad UnInit==>WaitForStop().");
WaitForStop();
g_pLogger->information("CFileUpLoad UnInit==>WaitForStop() completed.");
if (m_pITcpClient)
{
m_pITcpClient->ReleaseConnections();
m_pITcpClient = NULL;
}
mutexObj.Lock();
std::list<stUpLoadAns*>::iterator it1 = m_listFile.begin();
for (; it1 != m_listFile.end(); )
{
stUpLoadAns* itUp = *it1;
it1 = m_listFile.erase(it1);
SAFE_RELEASE(itUp);
}
m_listFile.clear();
mutexObj.Unlock();
// m_VecAns.clear();
std::vector<stUpLoadAns*>::iterator it = m_VecAns.begin();
for (; it != m_VecAns.end(); it++)
{
if (*it)
{
delete (*it);
(*it) = NULL;
}
}
std::list<pstUpLoadAddr>::iterator itAddr = m_UpLoadAddrList.begin();
for (; itAddr != m_UpLoadAddrList.end();)
{
pstUpLoadAddr pUpLoadAddr = *itAddr;
itAddr = m_UpLoadAddrList.erase(itAddr);
SAFE_RELEASE(pUpLoadAddr);
}
}
示例11: UnRegisterDrawClock
BOOL CTxWndDrawClockMgr::UnRegisterDrawClock( ST_DRAWCLOCKDATA& data )
{
g_mutexDrawClock.Lock(1000);
m_mapClockData.erase(data.hwnd);
if (m_mapClockData.size() == 0)
{
if (m_hThread != NULL)
{
TerminateThread(m_hThread, 0);
CloseHandle(m_hThread);
m_hThread = NULL;
}
}
g_mutexDrawClock.Unlock();
return TRUE;
}
示例12: SendAnsFile
BOOL CFileUpLoad::SendAnsFile(CString strFilePath, CString strFileName, void* pTask)
{
stUpLoadAns* stAns = new stUpLoadAns();
stAns->strAnsName = strFileName;
stAns->strPath = strFilePath;
stAns->bUpload = FALSE;
stAns->pTask = pTask;
#if 1
mutexObj.Lock();
m_listFile.push_back(stAns);
mutexObj.Unlock();
#else
m_VecAns.push_back(stAns);
#endif
TRACE(_T("add ans file %s\n"), strFileName);
SetEvent(m_hAddAnsEvent);
return TRUE;
}
示例13: Wait
void CCondition::Wait(CMutex &mutex)
{
#if defined(COREARRAY_POSIX_THREAD)
int v = pthread_cond_wait(&cond, &mutex.mutex);
if (v != 0)
throw ErrThread(ERR_PTHREAD, "pthread_cond_wait", v);
#elif defined(COREARRAY_PLATFORM_WINDOWS)
// increase the number of waiters
EnterCriticalSection(&cond.waiter_count_mutex);
cond.waiter_count ++;
LeaveCriticalSection(&cond.waiter_count_mutex);
// release the mutex object
mutex.Unlock();
// wait for either event to become signaled
DWORD rv = WaitForMultipleObjects(2, cond.events, FALSE, INFINITE);
if (rv == WAIT_TIMEOUT)
throw ErrThread("condition object wait time out.");
else if (rv == WAIT_FAILED)
throw ErrThread(LastSysErrMsg());
// check if we are the last waiter
EnterCriticalSection(&cond.waiter_count_mutex);
cond.waiter_count --;
bool IsLast = (rv == (WAIT_OBJECT_0 + 1)) && (cond.waiter_count == 0);
LeaveCriticalSection(&cond.waiter_count_mutex);
// reset the event if last waiter
if (IsLast)
{
if (ResetEvent(cond.events[1]) == 0)
throw ErrThread(LastSysErrMsg());
}
// Re-acquire the mutex
mutex.Lock();
#endif
}
示例14: ReadData
/*
* Reads the received numberOfScans scans from the device. If not enough data is available (errorCode == 2) or the application buffer overruns (errorCode == 1), this method returns false.
* float* destBuffer: the array that returns the received data from the application data buffer.
Data is aligned as follows: element at position destBuffer[scanIndex * numChannels + channelIndex] is sample of channel channelIndex (zero-based) of the scan with zero-based scanIndex.
channelIndex ranges from 0..numChannelsPerDevices where numChannelsPerDevice the total number of channels of the device including the trigger line.
* int numberOfScans: the number of scans to retrieve from the application buffer.
*/
bool ReadData(float* destBuffer, int numberOfScans, int *errorCode, string *errorMessage)
{
int numChannels = NUMBER_OF_CHANNELS + (int) ENABLE_TRIGGER;
int validPoints = numChannels * numberOfScans;
//wait until requested amount of data is ready
if (_buffer.GetSize() < validPoints)
{
*errorCode = 2;
*errorMessage = "Not enough data available";
return false;
}
//acquire lock on the application buffer for reading
_bufferLock.Lock();
__try
{
//if buffer run over report error and reset buffer
if (_bufferOverrun)
{
_buffer.Reset();
*errorCode = 1;
*errorMessage = "Error on reading data from the application data buffer: buffer overrun.";
_bufferOverrun = false;
return false;
}
//copy the data from the application buffer into the destination buffer
_buffer.Read(destBuffer, validPoints);
}
__finally
{
_bufferLock.Unlock();
}
*errorCode = 0;
*errorMessage = "No error occured.";
return true;
}
示例15: close
//PRIVATE: Close the file
inline void CLog::close()
{
if(!m_f)
throw CMWEXCEPTION(EIDMW_ERR_UNKNOWN);
#ifndef WIN32
m_flock.l_type = F_UNLCK; /* tell it to unlock the region */
if( fcntl(fileno(m_f), F_SETLK, &m_flock) == -1) /* set the region to unlocked */
throw CMWEXCEPTION(EIDMW_ERR_UNKNOWN);
#endif
fclose(m_f);
m_f=NULL;
#ifdef WIN32
ReleaseMutex(LogMutex);
#else
m_mutex.Unlock();
#endif
}