• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ASSUME_LOCK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ASSUME_LOCK

// Find the newest neighbor object
CNeighbour* CNeighboursBase::GetNewest(PROTOCOLID nProtocol, int nState, int nNodeType) const
{
	ASSUME_LOCK( Network.m_pSection );

	const DWORD tNow = GetTickCount();
	DWORD tMinTime = 0xffffffff;
	CNeighbour* pNewestNeighbour = NULL;

	for ( POSITION pos = GetIterator() ; pos ; )
	{
		CNeighbour* pNeighbour = GetNext( pos );
		if ( ( nProtocol == PROTOCOL_ANY || nProtocol == pNeighbour->m_nProtocol ) &&
			 ( nState < 0 || nState == pNeighbour->m_nState ) &&
			 ( nNodeType < 0 || nNodeType == pNeighbour->m_nNodeType ) )
		{
			DWORD tTime = tNow - pNeighbour->m_tConnected;
			if ( tTime < tMinTime )
			{
				tMinTime = tTime;
				pNewestNeighbour = pNeighbour;
			}
		}
	}

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


示例2: ASSUME_LOCK

void CDownloadTransfer::Close(TRISTATE bKeepSource, DWORD nRetryAfter)
{
	ASSUME_LOCK( Transfers.m_pSection );

	SetState( dtsNull );

//	if ( m_nProtocol != PROTOCOL_BT && m_nProtocol != PROTOCOL_ED2K )
	CTransfer::Close();

	if ( CDownloadSource* pSource = m_pSource )
	{
		m_pSource = NULL;

		switch ( bKeepSource )
		{
		case TRI_TRUE:
			if ( pSource->m_bCloseConn && pSource->m_nGnutella )
				pSource->OnResumeClosed();
			else
				pSource->OnFailure( TRUE, nRetryAfter );
			break;
		case TRI_UNKNOWN:
			pSource->OnFailure( FALSE );
			break;
		case TRI_FALSE:
			pSource->Remove( FALSE, TRUE );
			break;
		}
	}

	if ( m_pDownload )
		m_pDownload->RemoveTransfer( this );
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:33,代码来源:DownloadTransfer.cpp


示例3: ASSUME_LOCK

INT_PTR CDownloadSheet::DoModal()
{
	ASSUME_LOCK( Transfers.m_pSection );

	CTorrentFilesPage		pFiles;
	CTorrentTrackersPage	pTrackers;
	CTorrentGeneralPage		pGeneral;
	CDownloadEditPage		pDownload;
	CDownloadActionsPage	pActions;

	if ( m_pDownload->IsTorrent() )
	{
		SetTabTitle( &pFiles, m_sFilesTitle );
		AddPage( &pFiles );
		SetTabTitle( &pTrackers, m_sTrackersTitle );
		AddPage( &pTrackers );
		SetTabTitle( &pGeneral, m_sGeneralTitle );
		AddPage( &pGeneral );
	}

	if ( ! m_pDownload->IsMoving() && ! m_pDownload->IsCompleted() )
	{
		SetTabTitle( &pDownload, m_sDownloadTitle );
		AddPage( &pDownload );
		SetTabTitle( &pActions, m_sActionsTitle );
		AddPage( &pActions );
	}

	return CPropertySheetAdv::DoModal();
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:30,代码来源:DlgDownloadSheet.cpp


示例4: ASSUME_LOCK

void CDatagrams::remove(DatagramOut* pDatagramOut)
{
	ASSUME_LOCK(m_pSection);

	m_SendCacheMap.remove(pDatagramOut->m_nSequence);

	QLinkedList<DatagramOut*>::iterator itFrame = m_SendCache.end();
	while( itFrame != m_SendCache.begin() )
	{
		--itFrame;

		if( *itFrame == pDatagramOut )
		{
			m_SendCache.erase(itFrame);
			break;
		}
	}

	m_FreeDatagramOut.append(pDatagramOut);

	if(pDatagramOut->m_pBuffer)
	{
		m_FreeBuffer.append(pDatagramOut->m_pBuffer);
		pDatagramOut->m_pBuffer->clear();
		pDatagramOut->m_pBuffer = 0;
	}
}
开发者ID:quazaa-development-team,项目名称:quazaa,代码行数:27,代码来源:datagrams.cpp


示例5: ASSUME_LOCK

bool CDownloadTransferBT::UnrequestRange(QWORD nOffset, QWORD nLength)
{
	ASSUME_LOCK( Transfers.m_pSection );

	if ( m_oRequested.empty() ) 
		return false;

	ASSERT( m_pDownload->m_pTorrent.m_nBlockSize != 0 );
	if ( m_pDownload->m_pTorrent.m_nBlockSize == 0 )
		return false;

	Fragments::Queue oUnrequests = extract_range( m_oRequested,
		Fragments::Fragment( nOffset, nOffset + nLength ) );

	for ( Fragments::Queue::const_iterator pFragment = oUnrequests.begin();
		pFragment != oUnrequests.end(); ++pFragment )
	{
		m_pClient->Cancel(
			(DWORD)( pFragment->begin() / m_pDownload->m_pTorrent.m_nBlockSize ),
			(DWORD)( pFragment->begin() % m_pDownload->m_pTorrent.m_nBlockSize ),
			(DWORD)( pFragment->size() ) );
	}

	return !oUnrequests.empty();
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:25,代码来源:DownloadTransferBT.cpp


示例6: CNetworkConnection

CTransfer::CTransfer(void* pOwner, QObject *parent) :
	CNetworkConnection(parent),
	m_pOwner(pOwner)
{
	ASSUME_LOCK(Transfers.m_pSection);
	Transfers.add(this);
}
开发者ID:aboduo,项目名称:quazaa,代码行数:7,代码来源:transfer.cpp


示例7: ASSUME_LOCK

CFileList* CLibraryMaps::WhatsNew(const CQuerySearch* pSearch, int nMaximum) const
{
	ASSUME_LOCK( Library.m_pSection );

	const DWORD tNow = static_cast< DWORD >( time( NULL ) );
	CFileList* pHits = NULL;

	for ( POSITION pos = GetFileIterator() ; pos ; )
	{
		CLibraryFile* pFile = GetNextFile( pos );

		if ( pFile->IsAvailable() && pFile->IsShared() && pFile->m_oSHA1 &&
			( ! pSearch->m_pSchema || pSearch->m_pSchema->Equals( pFile->m_pSchema ) ) )
		{
			const DWORD nTime = pFile->GetCreationTime();
			if ( nTime && nTime + 12 * 60 * 60 > tNow )		// 12 hours
			{
				pFile->m_nHitsToday++;
				pFile->m_nHitsTotal++;

				if ( ! pHits )
					pHits = new CFileList;
				pHits->AddTail( pFile );
				if ( nMaximum && pHits->GetCount() >= nMaximum )
					break;
			}
		}
	}

	return pHits;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:31,代码来源:LibraryMaps.cpp


示例8: ASSUME_LOCK

bool CLibraryTileItem::Update()
{
	ASSUME_LOCK( Library.m_pSection );

	if ( m_pAlbum->m_nUpdateCookie == m_nCookie ) return false;

	m_nCookie		= m_pAlbum->m_nUpdateCookie;
	m_sTitle		= m_pAlbum->m_sName;
	m_nIcon32		= m_pAlbum->m_pSchema ? m_pAlbum->m_pSchema->m_nIcon32 : -1;
	m_nIcon48		= m_pAlbum->m_pSchema ? m_pAlbum->m_pSchema->m_nIcon48 : -1;
	m_bCollection	= m_pAlbum->m_oCollSHA1.isValid();

	CSchemaPtr pSchema = m_pAlbum->m_pSchema;

	if ( pSchema != NULL && m_pAlbum->m_pXML != NULL )
	{
		m_sSubtitle1 = pSchema->m_sTileLine1;
		m_sSubtitle2 = pSchema->m_sTileLine2;

		pSchema->ResolveTokens( m_sSubtitle1, m_pAlbum->m_pXML );
		pSchema->ResolveTokens( m_sSubtitle2, m_pAlbum->m_pXML );
	}
	else
	{
		m_sSubtitle1.Empty();
		m_sSubtitle2.Empty();
	}

	return true;
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:30,代码来源:CtrlLibraryTileView.cpp


示例9: ASSUME_LOCK

void CDownloadWithSources::InternalAdd(CDownloadSource* pSource)
{
	ASSUME_LOCK( Transfers.m_pSection );

	ASSERT( m_pSources.Find( pSource ) == NULL );
	m_pSources.AddTail( pSource );

	switch ( pSource->m_nProtocol )
	{
	case PROTOCOL_G1:
		m_nG1SourceCount++;
		break;
	case PROTOCOL_G2:
		m_nG2SourceCount++;
		break;
	case PROTOCOL_ED2K:
		m_nEdSourceCount++;
		break;
	case PROTOCOL_BT:
		m_nBTSourceCount++;
		break;
	case PROTOCOL_HTTP:
		m_nHTTPSourceCount++;
		break;
	case PROTOCOL_FTP:
		m_nFTPSourceCount++;
		break;
	case PROTOCOL_DC:
		m_nDCSourceCount++;
		break;
	default:
		ASSERT( FALSE );
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:34,代码来源:DownloadWithSources.cpp


示例10: ASSUME_LOCK

BOOL CHostBrowser::StreamPacketsG2()
{
	ASSUME_LOCK( Transfers.m_pSection );
	ASSERT( m_nProtocol == PROTOCOL_G2 );

	while ( CG2Packet* pPacket = CG2Packet::ReadBuffer( m_pBuffer ) )
	{
		BOOL bSuccess = FALSE;

		try
		{
			bSuccess = OnPacket( pPacket );
		}
		catch ( CException* pException )
		{
			pException->Delete();
		}

		pPacket->Release();

		if ( ! bSuccess )
		{
			Stop();
			return FALSE;
		}
	}

	return TRUE;
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:29,代码来源:HostBrowser.cpp


示例11: ASSUME_LOCK

const CQueryHashTable* CLibraryDictionary::GetHashTable()
{
	ASSUME_LOCK( Library.m_pSection );

	BuildHashTable();

	return m_pTable;
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:8,代码来源:LibraryDictionary.cpp


示例12: ASSUME_LOCK

void CNeighboursConnections::RemoveNode(CNeighbour* pNode)
{
	ASSUME_LOCK(m_pSection);

	m_pController->RemoveSocket(pNode);

	CNeighboursRouting::RemoveNode(pNode);
}
开发者ID:aboduo,项目名称:quazaa,代码行数:8,代码来源:neighboursconnections.cpp


示例13: ASSUME_LOCK

BOOL CManagedSearch::Execute(int nPriorityClass)
{
	ASSUME_LOCK( SearchManager.m_pSection );

	if ( m_nPriority != nPriorityClass || ! m_bActive || ! m_pSearch )
		return FALSE;

	// Throttle this individual search (so it doesn't take up too many resources)
	DWORD nThrottle = Settings.Search.GeneralThrottle;
	if ( m_nPriority == spLowest )
		nThrottle += 30000; // + 30s
	else if ( m_nPriority == spMedium )
		nThrottle += 800;	// + .8s

	const DWORD tTicks = GetTickCount();
	const DWORD tSecs = static_cast< DWORD >( time( NULL ) );

	if ( tTicks < m_tExecute + nThrottle )
		return FALSE;
	m_tExecute = tTicks;

	// Search local neighbours: hubs, servers and ultrapeers. (TCP)
	BOOL bSuccess = ExecuteNeighbours( tTicks, tSecs );

	// G1 multicast search. (UDP)
	if ( Settings.Gnutella1.Enabled && m_bAllowG1 &&
		 tTicks >= m_tLastG1 + Settings.Gnutella1.QueryGlobalThrottle &&
		 Network.IsListening() )
	{
		bSuccess |= ExecuteG1Mesh( tTicks, tSecs );
		m_tLastG1 = tTicks;
	}

	// G2 global search. (UDP)
	if ( Settings.Gnutella2.Enabled && m_bAllowG2 &&
		 tTicks >= m_tLastG2 + Settings.Gnutella2.QueryGlobalThrottle &&
		 Network.IsListening() )
	{
		bSuccess |= ExecuteG2Mesh( tTicks, tSecs );
		m_tLastG2 = tTicks;
	}

	// ED2K global search. (UDP)
	if ( Settings.eDonkey.Enabled &&
		 Settings.eDonkey.ServerWalk &&
		 m_bAllowED2K &&
		 tTicks >= m_tLastED2K + Settings.eDonkey.QueryGlobalThrottle &&
		 Network.IsListening() &&
		 ( m_pSearch->m_oED2K || IsLastSearch() ) )
	{
		bSuccess |= ExecuteDonkeyMesh( tTicks, tSecs );
		m_tLastED2K = tTicks;
	}

	if ( bSuccess ) m_nQueryCount++;

	return bSuccess;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:58,代码来源:ManagedSearch.cpp


示例14: ASSUME_LOCK

BOOL CUploadTransferDC::OnWrite()
{
	ASSUME_LOCK( Transfers.m_pSection );
	ASSERT( m_pClient );

	m_mOutput.tLast = m_pClient->m_mOutput.tLast;

	if ( m_pClient->GetOutputLength() != 0 )
		// There is data in output buffer
		return TRUE;

	if ( m_nState == upsUploading )
	{
		ASSERT( m_nLength != SIZE_UNKNOWN );

		// No file data left to transfer
		if ( m_nPosition >= m_nLength )
		{
			// File completed

			Uploads.SetStable( GetAverageSpeed() );

			m_nState = upsRequest;
			m_tRequest = GetTickCount();

			m_pBaseFile->AddFragment( m_nOffset, m_nLength );

			theApp.Message( MSG_INFO, IDS_UPLOAD_FINISHED, (LPCTSTR)m_sName, (LPCTSTR)m_sAddress );
		}
		else
		{
			// Reading next data chunk of file
			QWORD nToRead = min( m_nLength - m_nPosition, (QWORD)Settings.Uploads.ChunkSize );	// ~1000 KB
			QWORD nRead = 0;
			auto_array< BYTE > pBuffer( new BYTE[ nToRead ] );
			if ( ! ReadFile( m_nFileBase + m_nOffset + m_nPosition, pBuffer.get(), nToRead, &nRead ) || nToRead != nRead )
			{
				// File error
				return FALSE;
			}
			m_pClient->Write( pBuffer.get(), (DWORD)nRead );

			m_nPosition += nRead;
			m_nUploaded += nRead;

			Statistics.Current.Uploads.Volume += ( nRead / 1024 );
		}
	}
	else if ( m_nState >= upsResponse )
	{
		// Current transfer completed
		m_nState	= ( m_nState == upsPreQueue ) ? upsQueued : upsRequest;
		m_tRequest	= GetTickCount();
	}

	return TRUE;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:57,代码来源:UploadTransferDC.cpp


示例15: ASSUME_LOCK

POSITION CUploadsCtrl::GetFileIterator(CUploadQueue* pQueue)
{
	ASSUME_LOCK( Transfers.m_pSection );

	if ( pQueue == UploadQueues.m_pTorrentQueue )
	{
		for ( POSITION posNext = UploadFiles.GetIterator() ; posNext ; )
		{
			POSITION posThis = posNext;
			CUploadFile* pFile = UploadFiles.GetNext( posNext );
			CUploadTransfer* pTransfer = pFile->GetActive();
			if ( pTransfer == NULL || pTransfer->m_nState == upsNull ) continue;
			if ( pTransfer->m_nProtocol != PROTOCOL_BT ) continue;
			return posThis;
		}
		
		return NULL;
	}
	else if ( pQueue == UploadQueues.m_pHistoryQueue )
	{
		for ( POSITION posNext = UploadFiles.GetIterator() ; posNext ; )
		{
			POSITION posThis = posNext;
			CUploadFile* pFile = UploadFiles.GetNext( posNext );
			CUploadTransfer* pTransfer = pFile->GetActive();
			if ( pTransfer != NULL )
			{
				if ( pTransfer->m_nProtocol == PROTOCOL_BT && pTransfer->m_nState != upsNull ) continue;
				if ( pTransfer->m_pQueue != NULL ) continue;
			}
			return posThis;
		}
		
		return NULL;
	}
	else
	{
		if ( Settings.Uploads.FilterMask & ULF_ACTIVE )
		{
			if ( pQueue->GetActiveCount() > 0 )
			{
				return pQueue->GetActiveIterator();
			}
		}
		
		if ( Settings.Uploads.FilterMask & ULF_QUEUED )
		{
			if ( pQueue->GetQueuedCount() > 0 )
			{
				return (POSITION)1;
			}
		}
		
		return NULL;
	}
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:56,代码来源:CtrlUploads.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ASTNode_free函数代码示例发布时间:2022-05-30
下一篇:
C++ ASSUME函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap