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


C++ FileInfo::GetExtraPriority方法代码示例

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


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

示例1: Run

void QueueCoordinator::Run()
{
    debug("Entering QueueCoordinator-loop");

    Load();
    AdjustDownloadsLimit();
    bool bWasStandBy = true;
    bool bArticeDownloadsRunning = false;
    int iResetCounter = 0;
    g_pStatMeter->IntervalCheck();

    while (!IsStopped())
    {
        bool bDownloadsChecked = false;
        bool bDownloadStarted = false;
        NNTPConnection* pConnection = g_pServerPool->GetConnection(0, NULL, NULL);
        if (pConnection)
        {
            // start download for next article
            FileInfo* pFileInfo;
            ArticleInfo* pArticleInfo;
            bool bFreeConnection = false;

            DownloadQueue* pDownloadQueue = DownloadQueue::Lock();
            bool bHasMoreArticles = GetNextArticle(pDownloadQueue, pFileInfo, pArticleInfo);
            bArticeDownloadsRunning = !m_ActiveDownloads.empty();
            bDownloadsChecked = true;
            m_bHasMoreJobs = bHasMoreArticles || bArticeDownloadsRunning;
            if (bHasMoreArticles && !IsStopped() && (int)m_ActiveDownloads.size() < m_iDownloadsLimit &&
                    (!g_pOptions->GetTempPauseDownload() || pFileInfo->GetExtraPriority()))
            {
                StartArticleDownload(pFileInfo, pArticleInfo, pConnection);
                bArticeDownloadsRunning = true;
                bDownloadStarted = true;
            }
            else
            {
                bFreeConnection = true;
            }
            DownloadQueue::Unlock();

            if (bFreeConnection)
            {
                g_pServerPool->FreeConnection(pConnection, false);
            }
        }

        if (!bDownloadsChecked)
        {
            DownloadQueue::Lock();
            bArticeDownloadsRunning = !m_ActiveDownloads.empty();
            DownloadQueue::Unlock();
        }

        bool bStandBy = !bArticeDownloadsRunning;
        if (bStandBy != bWasStandBy)
        {
            g_pStatMeter->EnterLeaveStandBy(bStandBy);
            bWasStandBy = bStandBy;
            if (bStandBy)
            {
                SavePartialState();
            }
        }

        // sleep longer in StandBy
        int iSleepInterval = bDownloadStarted ? 0 : bStandBy ? 100 : 5;
        usleep(iSleepInterval * 1000);

        if (!bStandBy)
        {
            g_pStatMeter->AddSpeedReading(0);
        }

        Util::SetStandByMode(bStandBy);

        iResetCounter += iSleepInterval;
        if (iResetCounter >= 1000)
        {
            // this code should not be called too often, once per second is OK
            g_pServerPool->CloseUnusedConnections();
            ResetHangingDownloads();
            if (!bStandBy)
            {
                SavePartialState();
            }
            iResetCounter = 0;
            g_pStatMeter->IntervalCheck();
            AdjustDownloadsLimit();
        }
    }

    // waiting for downloads
    debug("QueueCoordinator: waiting for Downloads to complete");
    bool completed = false;
    while (!completed)
    {
        DownloadQueue::Lock();
        completed = m_ActiveDownloads.size() == 0;
        DownloadQueue::Unlock();
//.........这里部分代码省略.........
开发者ID:X0nic,项目名称:nzbget,代码行数:101,代码来源:QueueCoordinator.cpp


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