Beispiel #1
0
int
ts_main(int argc, char *argv[])
{
	unsigned i, ntasks, n, skip;
	TaskInfo_t *ti, *info;
	bool enabled[NVCONS];
	bool check_cons = false;				// por defecto habilitar todas las consolas
	bool cursor;
	(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CURSOR,2,false,&cursor);

	memset(enabled, 0, sizeof enabled);
	for ( i = 1 ; i < argc ; i++ )			// habilitar las consolas especificadas
	{
		unsigned cons = atoi(argv[i]);
		if ( cons < NVCONS )
			enabled[cons] = check_cons = true;
	}

	(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CLEAR,0);
	cprintk(WHITE, BLUE, "%s", title);
	(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_GOTOXY,2,0,24);
	cprintk(WHITE, BLUE, "%s", foot);
	skip = 0;
	do
	{
		info = GetTasks(&ntasks);
		for ( n = 0, i = 1, ti = info ; i < 24 && ntasks-- ; ti++ )
		{
			if ( (check_cons && !enabled[ti->consnum]) || n++ < skip )
				continue;
			(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_GOTOXY,2,0,i++);
			char namebuf[20];
			sprintf(namebuf, ti->protected ? "[%.16s]" : "%.18s", name(ti->task));
			cprintk(WHITE, BLACK, "%8x %-18s %u %10u %-9s %-18.18s", ti->task, namebuf, 
				ti->consnum, ti->priority, statename(ti->state), name(ti->waiting));
			if ( ti->is_timeout )
				cprintk(WHITE, BLACK, " %10u", ti->timeout);
			else
				(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CLREOL,0);
		}
		while ( i < 24 )
		{
			(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_GOTOXY,2,0,i++);
			(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CLREOL,0);
		}
		Free(info);
	}
	while ( getuser(&skip) );
	(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CLEAR,0);
	(getDriver(CONS_DRIVER)->ioctl_driver)(CONS_CURSOR,2,cursor,NULL);
	return 0;
}
Beispiel #2
0
int
ts_main(int argc, char *argv[])
{
	unsigned i, ntasks, n, skip;
	TaskInfo_t *ti, *info;
	bool enabled[NVCONS];
	bool check_cons = false;				// por defecto habilitar todas las consolas
	bool cursor = mt_cons_cursor(false);

	memset(enabled, 0, sizeof enabled);
	for ( i = 1 ; i < argc ; i++ )			// habilitar las consolas especificadas
	{
		unsigned cons = atoi(argv[i]);
		if ( cons < NVCONS )
			enabled[cons] = check_cons = true;
	}

	mt_cons_clear();
	cprintk(WHITE, BLUE, "%s", title); // permite escribir con letra y fondo particular
	mt_cons_gotoxy(0, 24); // me ubica en un lugar en pantalla (X e Y) para deespues escribir.
	cprintk(WHITE, BLUE, "%s", foot);
	skip = 0;
	do
	{
		info = GetTasks(&ntasks);
		for ( n = 0, i = 1, ti = info ; i < 24 && ntasks-- ; ti++ )
		{
			if ( (check_cons && !enabled[ti->consnum]) || n++ < skip )
				continue;
			mt_cons_gotoxy(0, i++);
			char namebuf[20];
			sprintf(namebuf, ti->protected ? "[%.16s]" : "%.18s", name(ti->task));
			cprintk(WHITE, BLACK, "%8x %-18s %u %10u %-9s %-18.18s", ti->task, namebuf, 
				ti->consnum, ti->priority, statename(ti->state), name(ti->waiting));
			if ( ti->is_timeout )
				cprintk(WHITE, BLACK, " %10u", ti->timeout);
			else
				mt_cons_clreol();
		}
		while ( i < 24 )
		{
			mt_cons_gotoxy(0, i++);
			mt_cons_clreol();
		}
		Free(info);
	}
	while ( getuser(&skip) );
	mt_cons_clear();
	mt_cons_cursor(cursor);	
	return 0;
}
Beispiel #3
0
BObjectList<Task>* TaskFS::GetTasks(TaskList forList)
{
	Task				*tmpTask		= NULL;
	BObjectList<Task>	*taskTaskList	= new BObjectList<Task>();
	int32	i;
	//grab a up to date List of Items
	GetTasks();
	for (i = 0; i<tasks->CountItems();i++) {
		tmpTask=tasks->ItemAt(i);
		if (*(tmpTask->GetTaskList()) == forList)
			taskTaskList->AddItem(tmpTask);
	}
	return taskTaskList;
}
Beispiel #4
0
TError TCgroup::KillAll(int signal) const {
    std::vector<pid_t> tasks;
    TError error;

    L_ACT() << "KillAll " << signal << " " << *this << std::endl;

    error = GetTasks(tasks);
    if (!error) {
        for (const auto &pid : tasks) {
            if (kill(pid, signal) && errno != ESRCH) {
                error = TError(EError::Unknown, errno, StringFormat("kill(%d, %d)", pid, signal));
                L_ERR() << "Cannot kill process " << pid << " : " << error << std::endl;
            }
        }
    }

    return error;
}
Beispiel #5
0
Task* TaskFS::GetTask(BString forID)
{
	Task	*tmpTask	= NULL;
	int32	i			= 0;
	bool	found		= false;
	//grab a up to date List of Items
	GetTasks();
	while (i<tasks->CountItems() && found!=true)
	{
		tmpTask=tasks->ItemAt(i);
		found = tmpTask->ID() == forID;
		i++;
	}
	
	if (found == true)
		return tmpTask;
	else
		return NULL;
}
Server::State* Server::Connector::RequestState() {
	State* state;
	try {
		LOG_DEBUG("call RequestState ...");
		Initialize();
		if (user == NULL) {
			if(authtype.compare(BASIC_AUTH)==0){
				this->user = AuthenticateByLoginAndPassword();
			}else{
				this->user = AuthenticateByKerberos();
			}
			if (user == NULL) {
				throw "User is NULL";
			}
		}
		state = GetTasks();
	} catch (const exception& e) {
		LOG_ERROR("exception: %s", e.what());
		state = new Server::State(CONNECTION_STATE_ERROR);
	} catch (const char* e) {
		LOG_ERROR("exception: %s", e);
		state = new Server::State(CONNECTION_STATE_ERROR);
	} catch (const string e) {
		LOG_ERROR("exception: %s", e.c_str());
		state = new Server::State(CONNECTION_STATE_ERROR);
	} catch (const wstring e) {
		LOG_ERROR_W(L"exception: " + e);
		state = new Server::State(CONNECTION_STATE_ERROR);
	} catch(...) {
		LOG_ERROR("General exception catched");
		state = new Server::State(CONNECTION_STATE_ERROR);
	}
	if (state->GetConnectionState() == CONNECTION_STATE_ERROR) {
		Reset();
	}
	return state;
}
void TeamWorkApi::ParseTasks( int iFollowupPage ){
   QScopedPointer<QDomDocument> pdomTaskLists( FutureParseResponse( "task-lists", strCurrentRequest ) );
   if( !pdomTaskLists )
      return;
   
   QDomElement domTaskList = pdomTaskLists->firstChildElement( "todo-lists" ).firstChildElement( "todo-list" );
   int i = 0;

   while( !domTaskList.isNull() ){
      int idTaskList = domTaskList.namedItem( "id" ).firstChild().nodeValue().toInt();
      QDomElement domTask = domTaskList.namedItem( "todo-items" ).firstChildElement( "todo-item" );

      while( !domTask.isNull() ){
         TwpmTask *pTask = new TwpmTask();
         pTask->strAuthor = domTask.namedItem( "responsible-party-names" ).firstChild().nodeValue();
         pTask->strContent = domTask.namedItem( "content" ).firstChild().nodeValue();
         pTask->idTaskList = idTaskList;
         pTask->id = domTask.namedItem( "id" ).firstChild().nodeValue().toInt();

         hashTempTasks.insert( pTask->id, pTask );

         domTask = domTask.nextSiblingElement( "todo-item" );
      }

      domTaskList = domTaskList.nextSiblingElement( "todo-list" );
      i++;

      if( 0 == i % 10 )
         QCoreApplication::processEvents();
   }

   if( bMultiPage )
      GetTasks( idCurrent, iFollowupPage );
   else
      emit ReturnTasks( this->idCurrent, hashTempTasks );
}
Beispiel #8
0
	};
	auto superDestroyedHandler = [this](CCircuitUnit* unit, CEnemyUnit* attacker) {
		IUnitTask* task = unit->GetTask();
		task->OnUnitDestroyed(unit, attacker);  // can change task
		unit->GetTask()->RemoveAssignee(unit);  // Remove unit from IdleTask
	};

	/*
	 * Defend buildings handler
	 */
	auto structDamagedHandler = [this](CCircuitUnit* unit, CEnemyUnit* attacker) {
		const AIFloat3& pos = unit->GetPos(this->circuit->GetLastFrame());
		CTerrainManager* terrainManager = this->circuit->GetTerrainManager();
		CDefendTask* defendTask = nullptr;
		float minSqDist = std::numeric_limits<float>::max();
		const std::set<IFighterTask*>& tasks = GetTasks(IFighterTask::FightType::DEFEND);
		for (IFighterTask* task : tasks) {
			CDefendTask* dt = static_cast<CDefendTask*>(task);
			if (dt->GetTarget() != nullptr) {
				continue;
			}
			const float sqDist = pos.SqDistance2D(dt->GetPosition());
			if ((minSqDist < sqDist) && (terrainManager->CanMoveToPos(dt->GetLeader()->GetArea(), pos))) {
				minSqDist = sqDist;
				defendTask = dt;
			}
		}
		if (defendTask != nullptr) {
			defendTask->SetPosition(pos);
			defendTask->SetWantedTarget(attacker);
		}
Beispiel #9
0
bool TCgroup::IsEmpty() const {
    std::vector<pid_t> tasks;

    GetTasks(tasks);
    return tasks.empty();
}