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


C++ JobQueue::push_back方法代码示例

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


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

示例1: run

    void JobScheduler::run(Ogre::Real time)
    {
        ///@todo use different buckets for jobs not yet started, instead of
        ///      iterating over those each time.

        ///@todo dynamically determine token threshold. Maybe make it work load depending.


        // Queue for finished jobs
        JobQueue notDone;

        for (JobQueue::iterator it = mJobQueue.begin(), end = mJobQueue.end(); it != end; ++it)
        {
            JobEntry entry = *it;

            TimeSource::TimeSourceType tst = entry.job->getTimeSource();
            TimeSource* ts = TimeSourceManager::getSingleton().getTimeSource(tst);
            Time clock = ts->getClock();
            if (tst != entry.timeSourceLastCall) // time source has changed, e.g. in a job queue
            {
                entry.timeLastCall = clock;
                entry.timeSourceLastCall = tst;
            }

            if (entry.markedToRemove)
            {
                // Notify listener, the job was removed
                if (entry.listener != NULL)
                {
                    entry.listener->jobRemoved(entry.ticket);
                }

                if (entry.job->destroyWhenDone() )
                {
                    delete entry.job;
                }
            }
            else if (entry.start <= clock && clock < entry.end)
            {
                // Is the token threshold reached?
                if (entry.tokens >= mTokenThreshold)
                {
                    // Yes, pay run fee and execute.
                    entry.tokens = 0;
                    bool runAgain = !entry.job->execute(clock - entry.timeLastCall);

                    if (!entry.called)
                    {
                        // Notify listener, the job started for the first time
                        if (entry.listener != NULL)
                        {
                            entry.listener->jobStarted(entry.ticket);
                        }
                        entry.called = true;
                    }

                    if (runAgain)
                    {
                        // Job is not done, reset token count and requeue.
                        entry.tokens = entry.priority;
                        entry.timeLastCall = clock;
                        notDone.push_back(entry);
                    }
                    else
                    {
                        // Notify listener, the job finished regularly.
                        if (entry.listener != NULL)
                        {
                            entry.listener->jobFinished(entry.ticket);
                        }

                        // If we are supposed to delete the Job, do so now.
                        if (entry.job->destroyWhenDone())
                        {
                            delete entry.job;
                        }
                    }
                }
                else
                {
                    // No, increase token count
                    entry.tokens += entry.priority;
                    notDone.push_back(entry);
                }
            }
            else if (clock < entry.end)
            {
                // Start time not yet reached. Queue again.
                notDone.push_back(entry);
            }
            else
            {
                // Job reached its end time and didn't want to finish itself, so we do it.
                if (entry.job->isDiscardable())
                {
                    entry.job->discard();
                    if (entry.listener != NULL)
                    {
                        entry.listener->jobDiscarded(entry.ticket);
                    }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:101,代码来源:JobScheduler.cpp


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