当前位置: 首页>>代码示例>>C++>>正文


C++ CCriticalSection::Unlock方法代码示例

本文整理汇总了C++中CCriticalSection::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CCriticalSection::Unlock方法的具体用法?C++ CCriticalSection::Unlock怎么用?C++ CCriticalSection::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCriticalSection的用法示例。


在下文中一共展示了CCriticalSection::Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: recv

unsigned int __stdcall Thread_RecvMsg(void *data)
{
	//int nNetTimeout = 30000;
	//setsockopt(sockClient,SOL_SOCKET,SO_RCVTIMEO,(char*)&nNetTimeout,sizeof(int));
	
	while(1)
	{

		int nRet = recv(sockClient,(char*)recvBuf,RECV_BUF_LEN,0);
		if((nRet == SOCKET_ERROR)|| (nRet == 0))
		{
			trySetConnectSocket(true);
			critical_section.Lock();
			if(exit_flag)
			{
				critical_section.Unlock();
				//shutdown(sockClient,SD_RECEIVE);
				shutdown(sockClient,SD_BOTH);
				closesocket(sockClient);
				return -1;
			}
			critical_section.Unlock();
			
			Sleep(2000);
		}
	}
}
开发者ID:miaozhendaoren,项目名称:ygomi_vscpp,代码行数:27,代码来源:InVehicle_EmulatorDlg.cpp

示例2: NewGUI_DoModal

INT_PTR NewGUI_DoModal(CDialog* pDlg)
{
	if(pDlg == NULL) { ASSERT(FALSE); return IDCANCEL; }

	CPwSafeDlg* pRootDlg = (CPwSafeDlg*)KPMI_GetMainDialog();
	ASSERT(pRootDlg != NULL);

	VERIFY(g_csDoModalRoot.Lock() != FALSE);
	if(pRootDlg != NULL)
	{
		pRootDlg->NotifyUserActivity();
		pRootDlg->_SetDisplayDialog(true);
	}
	VERIFY(CGlobalWindowManager::AddDialog(pDlg) == S_OK);
	VERIFY(g_csDoModalRoot.Unlock() != FALSE);

	const INT_PTR r = pDlg->DoModal();

	VERIFY(g_csDoModalRoot.Lock() != FALSE);
	VERIFY(CGlobalWindowManager::RemoveDialog(pDlg) == S_OK);
	if(pRootDlg != NULL)
	{
		pRootDlg->NotifyUserActivity();
		pRootDlg->_SetDisplayDialog(false);
	}
	VERIFY(g_csDoModalRoot.Unlock() != FALSE);

	return r;
}
开发者ID:xt9852,项目名称:KeePassXT,代码行数:29,代码来源:NewGUICommon.cpp

示例3: connect

//unsigned int __stdcall Thread_ReconnectSocket(void *data)
unsigned int __stdcall Thread_ReconnectSocket(LPVOID lpParam)
{
	ThreadProcInfo* pInfo =  (ThreadProcInfo*) lpParam;

	while(1)
	{
		
		WaitForSingleObject(g_readyEvent_ConnectSocket, INFINITE);
		WaitForSingleObject(socketMutex,INFINITE);
		critical_section.Lock();
		if(exit_flag)
		{
			//shutdown(sockClient,SD_BOTH);
			//closesocket(sockClient);	
			critical_section.Unlock();
			ResetEvent(g_readyEvent_ConnectSocket);
			ReleaseMutex(socketMutex);
			return -1;
		}
		critical_section.Unlock();

		
		while(SOCKET_ERROR == connect(sockClient,(struct sockaddr *)&serverAddr,sizeof(serverAddr)))
		{
			critical_section.Lock();
			if(exit_flag)
			{
				//shutdown(sockClient,SD_BOTH);
				//closesocket(sockClient);	
				critical_section.Unlock();
				ResetEvent(g_readyEvent_ConnectSocket);
				ReleaseMutex(socketMutex);
				return -1;
			}
			critical_section.Unlock();

			int errorCode = WSAGetLastError();
			if(errorCode == 10056 || errorCode == 10038)
			{
				closesocket(sockClient);

				while(INVALID_SOCKET == socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))
				{
					//printf("COMM: Creating socket failed!\n");
					PostMessage(pInfo->hWnd,WM_DISPLAYSTATUS,NULL,STATUS_CREATE_SOCKET_FAIL);
					Sleep(1000);
				}
			}
			//printf("COMM: Connect socket failed!\n");
			PostMessage(pInfo->hWnd,WM_DISPLAYSTATUS,NULL,STATUS_CONNECT_SOCKET_FAIL);
			Sleep(2000);
		}
		PostMessage(pInfo->hWnd,WM_DISPLAYSTATUS,NULL,STATUS_CONNECT_SOCKET_SUCCESS);

		ResetEvent(g_readyEvent_ConnectSocket);
		ReleaseMutex(socketMutex);
	}

}
开发者ID:miaozhendaoren,项目名称:ygomi_vscpp,代码行数:60,代码来源:InVehicle_EmulatorDlg.cpp

示例4: ProcessMessageServer

void CDummyWnd::ProcessMessageServer(CMessage *pMsg)
{
	COMMON_PACKET cmnpck;

	pMsg->GetData(&cmnpck, 0, sizeof(cmnpck));

	switch(cmnpck.header) // ÆÐŶ Çì´õ °Ë»ö
	{
		case GSM_SERVERINFO : // °ÔÀÓ ¼­¹ö Á¤º¸ÀÏ °æ¿ì
			{
				//AfxMessageBox("°ÔÀÓ ¼­¹ö Á¤º¸ ÀúÀå.");
				SERVERINFO si;
				CHANNELINFO ci;

				int nLen = pMsg->GetData(&si, 0, sizeof(si));  // ¿ì¼± °ÔÀÓ ¼­¹ö ÀÚüÀÇ Á¤º¸¸¦ ¾òÀ½

				LPSERVER server = m_ServerManager.GetServer((SOCKET)pMsg->GetSocket()); // ÆÐŶÀ» º¸³½ ¼­¹ö¸¦ ãÀ½

				if(server != NULL) // Á¤»óÀûÀÎ ¼­¹ö Æ÷ÀÎÅ͸¦ °¡Á®¿ÔÀ» °æ¿ì
				{
					server->id = si.id;	// ¼­¹öÀÇ ¾ÆÀ̵ð ÀúÀå
					server->ip = (char *)si.ip;	// ¾ÆÀÌÇÇ ÀúÀå
					server->portno = si.port;	// Æ÷Æ®¹øÈ£ ÀúÀå
					server->maxchannel = si.channels;
					server->rooms = si.rooms;

					if(!server->channel.size())	// ÃÖÃÊ¿¡ Á¢¼ÓÇÑ ¼­¹öÀÏ °æ¿ì ä³ÎÁ¤º¸°¡ ¾øÀ½
					{
						CHANNEL channel;

						for(int i = 0 ; i < si.channels ; i++) // Àüü ä³Î°¹¼ö¸¸Å­
						{
							nLen += pMsg->GetData(&ci, nLen, sizeof(ci)); // ä³Î Á¤º¸¸¦ Çϳª¾¿ Àоî¿È

							channel = ci;	// ä³ÎÁ¤º¸¸¦ Çϳª¾¿ ÀúÀå
							server->channel.push_back(channel); // ä³ÎÀ» ¸®½ºÆ®¿¡ Ãß°¡
						}
					}
					else // ÀÌ¹Ì Ã¤³Î Á¤º¸°¡ Á¸ÀçÇÒ °æ¿ì // ÁÖ±âÀûÀÎ ¼­¹ö Á¤º¸ÀÇ ¿äûÀÏ °æ¿ì
					{
						g_Critical.Lock();
						
						list<CHANNEL>::iterator i = server->channel.begin();
						
						for(; i != server->channel.end() ; i++)
						{
							LPCHANNEL lpchannel = &(*i);
							
							nLen += pMsg->GetData(&ci, nLen, sizeof(ci));
							
							*lpchannel = ci;
						}
						
						g_Critical.Unlock();
					}
				}
			}
			break;
	}
}
开发者ID:ShawnKim79,项目名称:OnlineCatan,代码行数:60,代码来源:DummyWnd.cpp

示例5: SMT_InsertOneTaskResult

//插入1条任务结果
bool CSmartCommunicationDlg::SMT_InsertOneTaskResult(SMARTTASKRESULT mTaskResult)
{	
	g_CriticalSectionLock.Lock();
	g_LSaveTaskResult.push_back(mTaskResult);	
	g_CriticalSectionLock.Unlock();
	return true;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:8,代码来源:SmartCommunicationDlg.cpp

示例6: UpdateLoadLog

//Thread safe way to update the load log
void CLoadLTADlg::UpdateLoadLog()
{

	CString sTextToAdd;

	g_LoadLogPipeCS.Lock(INFINITE);


	sTextToAdd = sm_sLoadLogPipe;
	sm_sLoadLogPipe = "";

	g_LoadLogPipeCS.Unlock();

	if(!sTextToAdd.IsEmpty())
	{
		CString sLogText;
		CEdit* pEdit = ((CEdit*)GetDlgItem(IDC_LOADLOG));

		pEdit->GetWindowText(sLogText);

		sLogText += sTextToAdd;
	
		pEdit->SetWindowText(sLogText);

		pEdit->LineScroll(pEdit->GetLineCount());
	}
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:28,代码来源:loadltadlg.cpp

示例7: StaticGetTotalBytesSent

long long EHS::StaticGetTotalBytesSent ( void )
{
    ms_StatsCS.Lock();
    long long llResult = ms_HttpTotalBytesSent;
    ms_StatsCS.Unlock();
    return llResult;
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:7,代码来源:ehs.cpp

示例8: StatsNumResponsesInc

void StatsNumResponsesInc( void )
{
    ms_StatsCS.Lock();
    ms_AllocationStats.uiTotalNumResponses++;
    ms_AllocationStats.uiActiveNumResponses++;
    ms_StatsCS.Unlock();
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:7,代码来源:ehs.cpp

示例9: StatsBytesAllocated

void StatsBytesAllocated( int nBodyLength )
{
    ms_StatsCS.Lock();
    ms_AllocationStats.uiTotalKBAllocated += nBodyLength / 1024;
    ms_AllocationStats.uiActiveKBAllocated += nBodyLength / 1024;
    ms_StatsCS.Unlock();
}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:7,代码来源:ehs.cpp

示例10: GetTickCountInternal

//
// Retrieves the number of milliseconds that have elapsed since some arbitrary point in time.
//
// GetTickCount64() exists on Vista and up and is like GetTickCount() except it returns
// an __int64 and will effectively never wrap. This is an emulated version for XP and down.
// Note: Wrap around issue is only defeated if the gap between calls is less than 24 days.
//
long long SharedUtil::GetTickCount64_ ( void )
{
    ms_criticalSection.Lock ();

    static long long llCurrent = ( GetTickCountInternal () % 300000 + 200000 );
    static uint uiWas      = GetTickCountInternal();
    uint        uiNow      = GetTickCountInternal();
    uint        uiDelta    = uiNow - uiWas;
    uiWas = uiNow;

    // Ensure delta is not negative
    if ( uiDelta > 0x80000000 )
        uiDelta = 0;

    // Or greater than 600 seconds
    if ( uiDelta > 600 * 1000 )
        uiDelta = 600 * 1000;

    // Add delta to accumulator
    llCurrent += uiDelta;

    // Add debug value
    llCurrent += ms_llTickCountAdd;
    ms_llTickCountAdd = 0;

    long long llResult = llCurrent;
    ms_criticalSection.Unlock ();
    return llResult;
}
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:36,代码来源:SharedUtil.Time.hpp

示例11: AddErrorMessenger

void LogManager::AddErrorMessenger(Logger::ErrorMessenger* messenger) 
{
	m_CritSection.Lock();
	S3D_ASSERT(messenger);
	m_errorMessengers.push_back(messenger);
	m_CritSection.Unlock();
}
开发者ID:Hesh0,项目名称:Sabre3D,代码行数:7,代码来源:Logger.cpp

示例12: ClearLoadLog

//Thread safe way to clear the load log
void CLoadLTADlg::ClearLoadLog()
{
	g_LoadLogPipeCS.Lock(INFINITE);

	sm_sLoadLogPipe = "";

	g_LoadLogPipeCS.Unlock();
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:9,代码来源:loadltadlg.cpp

示例13: SetLoadThreadDone

//Thread safe way to set if the loading thread is done
void CLoadLTADlg::SetLoadThreadDone(BOOL bDone)
{
	g_ThreadDoneCS.Lock(INFINITE);

	sm_bLoadThreadDone = bDone;
	
	g_ThreadDoneCS.Unlock();
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:9,代码来源:loadltadlg.cpp

示例14: AppendLoadLog

//Thread safe way to add text onto the end of the load log
void CLoadLTADlg::AppendLoadLog(const char* pszString)
{
	g_LoadLogPipeCS.Lock(INFINITE);

	sm_sLoadLogPipe += pszString;

	g_LoadLogPipeCS.Unlock();
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:9,代码来源:loadltadlg.cpp

示例15: OnObjmngDelete

void CDlgObjectManager::OnObjmngDelete()
{
	if(!m_hI) return;

	CCriticalSection cs;
	cs.Lock();
	CMyObject*	pObj;
	for( int i=0; i<m_pObPtrArray->GetSize(); i++) {
		pObj = m_pObPtrArray->GetAt(i);
		if( m_tree.GetItemText(m_hI) == pObj->GetIdName() ) {
			int res = AfxMessageBox("Delete? Sure?", MB_YESNO | MB_ICONQUESTION);
			if( res == IDYES ) {
				m_pObPtrArray->RemoveAt( i );
				m_tree.DeleteItem(m_hI);
				m_hI = NULL;
				cs.Unlock();
				m_pDoc->SetModifiedFlag();
				if( pObj->IsKindOf(RUNTIME_CLASS( CImgReferenced )) )
					m_pDoc->UpdateAllViews(NULL, UPDATE_BITMAP_DELETE);
				else if( pObj->IsKindOf(RUNTIME_CLASS(CGridObj)) )
					m_pDoc->UpdateAllViews(NULL, UPDATE_LEADHRZ_DELETE);
				else if( pObj->IsKindOf(RUNTIME_CLASS(CData3D)) )
					m_pDoc->UpdateAllViews(NULL, UPDATE_DATA3D_DELETE);
				else
					m_pDoc->UpdateAllViews(NULL);
				delete pObj;
				return;
			}
		}
	}

	CBody* pBd;
	pBd = (CBody*) FindBody(m_hI);
	if(pBd) {
		int res = AfxMessageBox("Delete Body? Sure?", MB_YESNO | MB_ICONQUESTION);
		if( res == IDYES ) {
			m_pDoc->GetModel()->DeleteBody( pBd->GetID() );
			m_tree.DeleteItem(m_hI);
			m_hI = NULL;
			m_pDoc->SetModifiedFlag();
			m_pDoc->UpdateAllViews(NULL, UPDATE_BODY_EDIT_DELETE);
		}
	}

	cs.Unlock();
}
开发者ID:igorcerovsky,项目名称:Mod3D,代码行数:46,代码来源:DlgPictureManager.cpp


注:本文中的CCriticalSection::Unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。