Пример #1
0
bool JobList::schedule(ProcessList &p,unsigned int time)
{
	if(hasJob() == false)
		return false;
	auto min = jlist.begin();
	bool sign = false;
	for(auto i = min; i != jlist.end(); ++i)
	{
		unsigned int m = getUnusedMem();
		if(i->stime <= time  && i->memory <= m)
		{
			if(i->ntime <= min->ntime || min->memory > m)
			{
				min = i;
				sign = true;
			}
		}
	}

	if(!sign)
		return false;

	if(NULL == ( min->memAddr = mm_malloc(min->memory)))
		return false;

	p.insertJobB(*min);	
	jlist.erase(min);
	return true;
}
Пример #2
0
void AvatarJobManager::scheduleJob()
{
	QMutexLocker(&mutex());

	if (!IsJobRunning && hasJob())
		// run it in next even cycle
		// this is for reccursion prevention, so we save on stack memory
		QTimer::singleShot(0, this, SLOT(runJob()));
}
Пример #3
0
Contact AvatarJobManager::nextJob()
{
	QMutexLocker(&mutex());

	if (!hasJob())
		return Contact::null;

	Contact job = *Jobs.constBegin();
	Jobs.remove(job);

	return job;
}
Пример #4
0
void AvatarJobManager::runJob()
{
	QMutexLocker(&mutex());

	if (IsJobRunning)
		return;

	if (!hasJob())
		return;

	IsJobRunning = true;

	Contact contact = nextJob();
	AvatarJobRunner *runner = new AvatarJobRunner(contact, this);
	connect(runner, SIGNAL(jobFinished(bool)), this, SLOT(jobFinished()));
	runner->runJob();
}