Exemple #1
0
/**
 * Moves thread with given id to blocked list.
 * Has no effect on blocked threads.
 */
void PriorityQueue::block(int id)
{
	int location = -1;
	vector<Thread *> * point = findInQueue(id , location);
	if (location != -1)
	{
		_Blocked.push_back(point->at(location));
		point->erase(point->begin() + location);
	}
}
Exemple #2
0
void PriorityQueue::removeElement(int id)
{
	int location = -1;
	vector<Thread  * > * point = findInQueue(id , location);
	if (location == -1)
	{
		location = findElement(id , _Blocked);
		if (location != -1)
		{
			point = &_Blocked;
		}
	}
	if (location != -1)
	{
		point->erase(point->begin() + location);
		decreaseSize();
	}
	return;
}
Exemple #3
0
StateChange * StateChanges::get(state from)
{
  StateChange * ret = NULL;
  states::iterator sq = findInQueue(from);  
  if(sq!=scq.end()){
    (*sq)->inc();
    ret = *sq;
    upgrade(sq);
    return ret;
  }
  states::iterator s = find(from);
  if(s!=sc.end()){
    (*s)->inc();
    StateChange * ss = (*s);
    ret = ss;
    sc.erase(s);
    insertSorted(ss);
  }
  return ret;
}