本文整理汇总了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;
}
示例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 );
}
示例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();
}
示例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;
}
}
示例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();
}
示例6: CNetworkConnection
CTransfer::CTransfer(void* pOwner, QObject *parent) :
CNetworkConnection(parent),
m_pOwner(pOwner)
{
ASSUME_LOCK(Transfers.m_pSection);
Transfers.add(this);
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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;
}
示例11: ASSUME_LOCK
const CQueryHashTable* CLibraryDictionary::GetHashTable()
{
ASSUME_LOCK( Library.m_pSection );
BuildHashTable();
return m_pTable;
}
示例12: ASSUME_LOCK
void CNeighboursConnections::RemoveNode(CNeighbour* pNode)
{
ASSUME_LOCK(m_pSection);
m_pController->RemoveSocket(pNode);
CNeighboursRouting::RemoveNode(pNode);
}
示例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;
}
示例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;
}
示例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;
}
}