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


C++ pLock函数代码示例

本文整理汇总了C++中pLock函数的典型用法代码示例。如果您正苦于以下问题:C++ pLock函数的具体用法?C++ pLock怎么用?C++ pLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: pLock

CCircuitry* CNeighbour::ConnectTo(LPCTSTR xUserId, DWORD nTimeOut)
{
	CSingleLock pLock( &m_pSection, TRUE );
	
	CCircuitry* pChannel = FindChannel( xUserId );
	if ( pChannel ) return pChannel;
	
	NETRESOURCE ns;
	
	ns.dwScope = RESOURCE_CONNECTED;   
	ns.dwType = RESOURCETYPE_ANY; 
	ns.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC;
	ns.dwUsage = RESOURCEUSAGE_CONNECTABLE;
	
	ns.lpRemoteName	= Settings.Centric.Remote.GetBuffer(0);
	ns.lpLocalName = NULL;
	ns.lpProvider = NULL;
	
	WNetAddConnection2( &ns, Settings.Centric.Password, Settings.Centric.UserId, 0 );
	
	if ( ! WaitNamedPipe( Settings.Centric.Remote, nTimeOut ) ) return NULL;
	
	pChannel = SetChannel( new CCircuitry( xUserId ) );
	pChannel->ConnectTo( Settings.Centric.Remote, nTimeOut  );
	
	pChannel->SendPacket( new CBindPacket( xUserId, "" ) );
	
	Connect(); return pChannel;
}
开发者ID:pics860,项目名称:callcenter,代码行数:29,代码来源:Neighbour.cpp

示例2: pLock

void CUploadsWnd::OnUploadsClear()
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	CList<CUploadFile*> pList;

	for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
	{
		CUploadFile* pFile = UploadFiles.GetNext( pos );
		if ( IsSelected( pFile ) ) pList.AddTail( pFile );
	}

	while ( ! pList.IsEmpty() )
	{
		CUploadFile* pFile = pList.RemoveHead();

		if ( UploadFiles.Check( pFile ) )
		{
			CUploadTransfer* pUpload = pFile->GetActive();

			if ( pUpload != NULL && pUpload->m_nProtocol == PROTOCOL_ED2K && pUpload->m_nState != upsNull )
			{
				CString strFormat, strMessage;
				LoadString( strFormat, IDS_UPLOAD_CANCEL_ED2K );
				strMessage.Format( strFormat, (LPCTSTR)pUpload->m_sFileName );
				pLock.Unlock();
				UINT nResp = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
				pLock.Lock();
				if ( nResp == IDCANCEL ) break;
				if ( nResp != IDYES || ! UploadFiles.Check( pFile ) ) continue;
			}

			pFile->Remove();
		}
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:35,代码来源:WndUploads.cpp

示例3: pLock

void CLibraryFileView::OnUpdateLibraryShared(CCmdUI* pCmdUI)
{
	if ( GetSelectedCount() < 1 )
	{
		pCmdUI->Enable( FALSE );
		pCmdUI->SetCheck( FALSE );
		return;
	}

	TRISTATE bShared = TRI_UNKNOWN;

	CSingleLock pLock( &Library.m_pSection );
	if ( pLock.Lock( 100 ) )
	{
		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			if ( bShared == TRI_UNKNOWN )
			{
				bShared = pFile->IsShared() ? TRI_TRUE : TRI_FALSE;
			}
			else if ( ( bShared == TRI_TRUE ) != pFile->IsShared() )
			{
				pCmdUI->Enable( FALSE );
				return;
			}
		}
		pLock.Unlock();
	}

	pCmdUI->Enable( TRUE );
	pCmdUI->SetCheck( bShared == TRI_TRUE );
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:33,代码来源:CtrlLibraryFileView.cpp

示例4: pLock

void CSearchMonitorWnd::OnTimer(UINT_PTR nIDEvent) 
{
	if ( nIDEvent != 2 ) return;

	BOOL bScroll = m_wndList.GetTopIndex() + m_wndList.GetCountPerPage() >= m_wndList.GetItemCount();

	for (;;)
	{
		CLiveItem* pItem;

		{
			CSingleLock pLock( &m_pSection );
			if ( ! pLock.Lock( 250 ) )
				break;

			if ( m_pQueue.GetCount() == 0 )
				break;

			pItem = m_pQueue.RemoveHead();
		}

		if ( (DWORD)m_wndList.GetItemCount() >= Settings.Search.MonitorQueue && Settings.Search.MonitorQueue > 0 )
		{
			m_wndList.DeleteItem( 0 );
		}

		/*int nItem =*/ pItem->Add( &m_wndList, -1, 4 );

		delete pItem;
	}

	if ( bScroll ) m_wndList.EnsureVisible( m_wndList.GetItemCount() - 1, FALSE );
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:33,代码来源:WndSearchMonitor.cpp

示例5: pLock

void CSearchWnd::OnFilters(UINT nID)
{
    if ( nID < 3000 ) return;
    const int nFilter = nID - 3000;

    {
        CQuickLock pLock( m_pMatches->m_pSection );

        if ( (DWORD)nFilter > m_pMatches->m_pResultFilters->m_nFilters - 1 ) return;

        m_pMatches->m_bFilterBusy		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterBusy;
        m_pMatches->m_bFilterPush		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterPush;
        m_pMatches->m_bFilterUnstable	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterUnstable;
        m_pMatches->m_bFilterReject		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterReject;
        m_pMatches->m_bFilterLocal		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterLocal;
        m_pMatches->m_bFilterBogus		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterBogus;
        m_pMatches->m_bFilterDRM		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterDRM;
        m_pMatches->m_bFilterAdult		= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterAdult;
        m_pMatches->m_bFilterSuspicious = m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_bFilterSuspicious;
        m_pMatches->m_nFilterMinSize	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterMinSize;
        m_pMatches->m_nFilterMaxSize	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterMaxSize;
        m_pMatches->m_nFilterSources	= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_nFilterSources;
        m_pMatches->m_sFilter			= m_pMatches->m_pResultFilters->m_pFilters[ nFilter ]->m_sFilter;

        m_pMatches->Filter();
    }

    Invalidate();
}
开发者ID:qing3962,项目名称:peerproject,代码行数:29,代码来源:WndSearch.cpp

示例6: pLock

void CDownloadGroups::CreateDefault()
{
	CSingleLock pLock( &m_pSection, TRUE );

	CDownloadGroup* pGroup	= GetSuperGroup();

	pGroup = Add( _T("Audio") );
	pGroup->AddFilter( _T(".mp3") );
	pGroup->AddFilter( _T(".ogg") );
	pGroup->AddFilter( _T(".wav") );
	pGroup->AddFilter( _T(".wma") );
	pGroup->SetSchema( CSchema::uriMusicAlbum );

	pGroup = Add( _T("Video") );
	pGroup->AddFilter( _T(".asf") );
	pGroup->AddFilter( _T(".avi") );
	pGroup->AddFilter( _T(".mov") );
	pGroup->AddFilter( _T(".mpg") );
	pGroup->AddFilter( _T(".mpeg") );
	pGroup->AddFilter( _T(".ogm") );
	pGroup->AddFilter( _T(".wmv") );
	pGroup->SetSchema( CSchema::uriVideo );

	pGroup = Add( _T("BitTorrent") );
	pGroup->AddFilter( _T("torrent") );
	pGroup->SetSchema( CSchema::uriROM );
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:27,代码来源:DownloadGroups.cpp

示例7: pLock

void CHashDatabase::Close()
{
	CSingleLock pLock( &m_pSection, TRUE );

	delete [] m_pIndex;

	if ( m_pFile.m_hFile != CFile::hFileNull )
	{
		try
		{
			m_pFile.Close();
		}
		catch ( CException* pException )
		{
			m_pFile.Abort();
			pException->Delete();
		}
	}

	m_bOpen		= FALSE;
	m_nOffset	= 0;
	m_pIndex	= NULL;
	m_nIndex	= 0;
	m_nBuffer	= 0;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:25,代码来源:HashDatabase.cpp

示例8: pLock

CTransferFile* CTransferFiles::Open(LPCTSTR pszFile, BOOL bWrite)
{
	CSingleLock pLock( &m_pSection, TRUE );

	CTransferFile* pFile = NULL;
	if ( m_pMap.Lookup( pszFile, pFile ) )
	{
		if ( bWrite && ! pFile->EnsureWrite() )
			return NULL;
	
		pFile->AddRef();
	}
	else
	{
		pFile = new CTransferFile( pszFile );
		if ( ! pFile->Open( bWrite ) )
		{
			DWORD dwError = GetLastError();
			pFile->Release();
			SetLastError( dwError );
			return NULL;
		}

		m_pMap.SetAt( pFile->m_sPath, pFile );

		TRACE( "Transfer Files : Opened \"%s\" [%s]\n", (LPCSTR)CT2A( pszFile ), ( bWrite ? "write" : "read" ) );
	}

	return pFile;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:30,代码来源:TransferFile.cpp

示例9: pLock

void CRemote::PageNewSearch()
{
	if ( CheckCookie() ) return;

	CMainWnd* pMainWnd = (CMainWnd*)theApp.m_pMainWnd;
	if ( pMainWnd == NULL || ! pMainWnd->IsKindOf( RUNTIME_CLASS(CMainWnd) ) ) return;

	CSingleLock pLock( &theApp.m_pSection );
	if ( ! SafeLock( pLock ) ) return;

	const CString strSearch = GetKey( L"search" );
	const CString strSchema = GetKey( L"schema" );

	if ( strSearch.IsEmpty() || ( ! strSchema.IsEmpty() && SchemaCache.Get( strSchema ) == NULL ) )
	{
		m_sRedirect = L"home";
		return;
	}

	CQuerySearchPtr pSearch	= new CQuerySearch();
	pSearch->m_sSearch		= strSearch;
	pSearch->m_pSchema		= SchemaCache.Get( strSchema );

	CString strURI;
	if ( pSearch->m_pSchema != NULL )
		strURI = pSearch->m_pSchema->GetURI();

	Settings.Search.LastSchemaURI = strURI;

	pMainWnd->PostMessage( WM_OPENSEARCH, (WPARAM)pSearch.Detach() );
	pLock.Unlock();
	Sleep( 500 );

	m_sRedirect = L"search";
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:35,代码来源:Remote.cpp

示例10: pLock

// Takes a protocol, like Gnutella, a state, like connecting, and a node connection type, like we are both ultrapeers
// Counts the number of neighbours in the list that match these criteria, pass -1 to count them all
DWORD CNeighboursBase::GetCount(PROTOCOLID nProtocol, int nState, int nNodeType) const
{
	DWORD nCount = 0;

	CSingleLock pLock( &Network.m_pSection, FALSE );
	if ( pLock.Lock( 200 ) )
	{
		for ( POSITION pos = GetIterator() ; pos ; )
		{
			CNeighbour* pNeighbour = GetNext( pos );

			// If this neighbour has the protocol we are looking for, or nProtocl is negative to count them all
			if ( nProtocol == PROTOCOL_ANY || nProtocol == pNeighbour->m_nProtocol )
			{
				// If this neighbour is currently in the state we are looking for, or nState is negative to count them all
				if ( nState < 0 || nState == pNeighbour->m_nState )
				{
					// If this neighbour is in the ultra or leaf role we are looking for, or nNodeType is null to count them all
					if ( nNodeType < 0 || nNodeType == pNeighbour->m_nNodeType )
						nCount++;
				}
			}
		}
	}

	return nCount;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:29,代码来源:NeighboursBase.cpp

示例11: KillTimer

void CDownloadMonitorDlg::OnDestroy()
{
	KillTimer( 1 );

	if ( m_pDownload != NULL )
	{
		CDownload* pDownload = m_pDownload;
		m_pDownload = NULL;

		CSingleLock pLock( &Transfers.m_pSection );
		if ( pLock.Lock( 250 ) )
		{
			if ( Downloads.Check( pDownload ) )
				pDownload->m_pMonitorWnd = NULL;
		}
	}

	if ( m_bTray )
	{
		Shell_NotifyIcon( NIM_DELETE, &m_pTray );
		m_bTray = FALSE;
	}

	CSkinDialog::OnDestroy();
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:25,代码来源:DlgDownloadMonitor.cpp

示例12: pLock

bool CLocalSearch::ExecutePartialFiles(INT_PTR nMaximum, INT_PTR& nHits)
{
	CSingleLock pLock( &Transfers.m_pSection );
	if ( ! pLock.Lock( 250 ) )
		return false;

	if ( ! m_pSearch || ! m_pSearch->m_bWantPFS || m_nProtocol != PROTOCOL_G2 )
		// Browse request, or no partials requested, or non Gnutella 2 request
		return true;

	CList< CDownload* > oFilesInPacket;

	for ( POSITION pos = Downloads.GetIterator() ;
		pos && ( ! nMaximum || ( nHits + oFilesInPacket.GetCount() < nMaximum ) ); )
	{
		CDownload* pDownload = Downloads.GetNext( pos );

		if ( IsValidForHit( pDownload ) )
		{
			oFilesInPacket.AddTail( pDownload );
		}
	}

	SendHits( oFilesInPacket );

	nHits += oFilesInPacket.GetCount();

	return true;
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:29,代码来源:LocalSearch.cpp

示例13: GetToolTip

void CLibraryFileView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	GetToolTip()->Hide();

	CStringList oFiles;
	{
		CQuickLock pLock( Library.m_pSection );
		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			oFiles.AddTail( pFile->GetPath() );
		}
	}

	if ( oFiles.GetCount() == 0 )
	{
		// No files were selected, try folder itself
		if ( CLibraryTreeItem* pRoot = GetFolderSelection() )
		{
			if ( pRoot->m_pPhysical )
				oFiles.AddTail( pRoot->m_pPhysical->m_sPath );
		}
	}

	if ( point.x == -1 && point.y == -1 )	// Keyboard fix
		ClientToScreen( &point );

	CString strName( m_pszToolBar );
//	strName += Settings.Library.ShowVirtual ? _T(".Virtual") : _T(".Physical");		// For now, CLibraryFileView.Virtual = CLibraryFileView.Physical

	Skin.TrackPopupMenu( strName, point, ID_LIBRARY_LAUNCH, oFiles );
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:32,代码来源:CtrlLibraryFileView.cpp

示例14: pLock

void CBaseMatchWnd::OnSearchForSeries() 
{
	CSingleLock pLock( &m_pMatches->m_pSection, TRUE );
	CRelatedSearch pSearch( m_pMatches->GetSelectedFile( TRUE ) );
	pLock.Unlock();
	pSearch.RunSearchForSeries();
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:7,代码来源:WndBaseMatch.cpp

示例15: pLock

BOOL CNetwork::AsyncResolve(LPCTSTR pszAddress, WORD nPort, PROTOCOLID nProtocol, BYTE nCommand)
{
	CSingleLock pLock( &m_pSection );
	if ( ! pLock.Lock( 250 ) ) return FALSE;
	
	BYTE* pResolve = (BYTE*)malloc( MAXGETHOSTSTRUCT + 8 );
	
	USES_CONVERSION;
	
	HANDLE hAsync = WSAAsyncGetHostByName( AfxGetMainWnd()->GetSafeHwnd(), WM_WINSOCK,
		T2CA(pszAddress), (LPSTR)pResolve + 8, MAXGETHOSTSTRUCT );
	
	if ( hAsync != NULL )
	{
		*((CString**)&pResolve[0])	= new CString( pszAddress );
		*((WORD*)&pResolve[4])		= nPort;
		*((BYTE*)&pResolve[6])		= nProtocol;
		*((BYTE*)&pResolve[7])		= nCommand;
		
		m_pLookups.SetAt( (LPVOID)hAsync, (LPVOID)pResolve );
		return TRUE;
	}
	else
	{
		free( pResolve );
		return FALSE;
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:28,代码来源:Network.cpp


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