本文整理汇总了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);
}
//.........这里部分代码省略.........