本文整理汇总了C++中AddTask函数的典型用法代码示例。如果您正苦于以下问题:C++ AddTask函数的具体用法?C++ AddTask怎么用?C++ AddTask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddTask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CFindPathTask
CBotTF2HealSched::CBotTF2HealSched(edict_t *pHeal)
{
CFindPathTask *findpath = new CFindPathTask(pHeal);
findpath->SetCompleteInterrupt(CONDITION_SEE_HEAL);
AddTask(findpath);
AddTask(new CBotTF2MedicHeal());
}
示例2: AddTask
///Adds a NEW task to the queue. Creates a queue if the tracks associated with the task is not in the list
///
///@param task the task to add
///@param lockMutex locks the mutexes if true (default). This function is used within other ODManager calls, which many need to set this to false.
void ODManager::AddNewTask(movable_ptr<ODTask> &&mtask, bool lockMutex)
{
auto task = mtask.get();
ODWaveTrackTaskQueue* queue = NULL;
if(lockMutex)
mQueuesMutex.Lock();
for(unsigned int i=0;i<mQueues.size();i++)
{
//search for a task containing the lead track. wavetrack removal is threadsafe and bound to the mQueuesMutex
//note that GetWaveTrack is not threadsafe, but we are assuming task is not running on a different thread yet.
if(mQueues[i]->ContainsWaveTrack(task->GetWaveTrack(0)))
queue = mQueues[i].get();
}
if(queue)
{
//Add it to the existing queue but keep the lock since this reference can be deleted.
queue->AddTask(std::move(mtask));
if(lockMutex)
mQueuesMutex.Unlock();
}
else
{
//Make a NEW one, add it to the local track queue, and to the immediate running task list,
//since this task is definitely at the head
auto newqueue = make_movable<ODWaveTrackTaskQueue>();
newqueue->AddTask(std::move(mtask));
mQueues.push_back(std::move(newqueue));
if(lockMutex)
mQueuesMutex.Unlock();
AddTask(task);
}
}
示例3: DispatchTask
void DispatchTask (void){
uint8_t n=0;
if (flags.RunFlag==1){ // если таймер выставил флаг
task tmp; // переменная для хранения нулевого элемента
tmp=TaskArray[0];
while (((TaskArray[n].pfunc != 0) || (TaskArray[n].countdown!=0)) && (n < MAXnTASKS)){
n++; //мотаем пока счетчик не дойдет до задачи с нужной задержкой
TaskArray[n-1]=TaskArray[n]; //сдвигаем очередь вперед
if (TaskArray[n-1].countdown) TaskArray[n-1].countdown-=dt; //вычитаем прошедшее время из каждой задачи
}
DeleteTask(n); //удаляем последнюю задачу
switch (tmp.numRun){
case 0: if (*tmp.nextfunc!=Idle) AddTask(*tmp.nextfunc,Idle,tmp.nextdelay,0,tmp.numRun);break;
case 0xffff: AddTask(*tmp.pfunc,*tmp.nextfunc,tmp.delay,tmp.nextdelay,tmp.numRun);break;
default: if (tmp.numRun&&tmp.numRun!=0xffff) AddTask(*tmp.pfunc,*tmp.nextfunc,tmp.delay,tmp.nextdelay,--tmp.numRun);break;
}
if (TaskArray[0].countdown!=0) {delay_time=TaskArray[0].countdown;} // если здесь +1 , то немного работает ))))
else {delay_time=1;} //можно флаг запуска добавить сюда , но в очереди будет нечего убавлять и ф-ию зациклит
dt=delay_time; //или воткнуть туда значение уменьшения , только его нужно брать для точности
(*tmp.pfunc)();
flags.RunFlag=0; //из расчета кол-ва тиков выполняемой функции и частоты прерывания таймера
}
}
示例4: Vector
CBotFollowLastEnemy::CBotFollowLastEnemy(CBot *pBot, edict_t *pEnemy, Vector vLastSee)
{
Vector vVelocity = Vector(0, 0, 0);
CClient *pClient = CClients::Get(pEnemy);
CFindPathTask *pFindPath = new CFindPathTask(vLastSee, LOOK_LAST_ENEMY);
if (CClassInterface::GetVelocity(pEnemy, &vVelocity))
{
if (pClient && (vVelocity == Vector(0, 0, 0)))
vVelocity = pClient->GetVelocity();
}
else if (pClient)
vVelocity = pClient->GetVelocity();
pFindPath->SetCompleteInterrupt(CONDITION_SEE_CUR_ENEMY);
AddTask(pFindPath);
/*if ( pBot->isTF2() )
{
int playerclass = ((CBotTF2*)pBot)->getClass();
if ( ( playerclass == TF_CLASS_SOLDIER ) || (playerclass == TF_CLASS_DEMOMAN) )
AddTask(new CBotTF2ShootLastEnemyPosition(vLastSee,pEnemy,vVelocity));
}*/
AddTask(new CFindLastEnemy(vLastSee, vVelocity));
//////////////
pFindPath->SetNoInterruptions();
}
示例5: AddTask
CBotTF2GetFlagSched::CBotTF2GetFlagSched(Vector vOrigin, bool bUseRoute, Vector vRoute)
{
if (bUseRoute)
AddTask(new CFindPathTask(vRoute));
AddTask(new CFindPathTask(vOrigin)); // first
AddTask(new CBotTF2WaitFlagTask(vOrigin)); // second
}
示例6: DS18B20InitializeSensorTask
void DS18B20InitializeSensorTask() {
DS18B20InitializeSensorAction();
if (DS18B20ResultInitializeSensor == DS18B20OperationOK) {
AddTask(DS18B20ConvertTemperatureTask, DS18B20ConvertTemperatureTaskDelay);
}
else {
AddTask(DS18B20InitializeSensorTask, DS18B20RepeatInitializeSensorTaskDelay);
}
}
示例7: main
int main(void)
{
init_scheduler();
AddTask(0,50, keypak, NULL);
AddTask(1, 20, keypak1, NULL);
AddTask(7, 500, NULL, NULL);
init_timer_irq();
execute();
}
示例8: main
void main(void) {
Init_Device();
#if WITH_TASKER
InitTasker();
led_task = AddTask(&LedToggle,1000,INFINITE_TASK);
#endif
#if WITH_BINDER
InitBinder();
#endif
P0 &= (~0x80);
#if WITH_COMM_LINK
StartCommLinkCommunication(0x26);
#endif
#if WITH_Z_UNO_CHANNEL_DEBUG
{
BYTE result = setupUserChannels();
}
#endif
#if WITH_LCD
LCD_Init_VIM878();
#endif
#if WITH_BUTTONS
ButtonsInit();
AddTask(ButtonsPoll, 10, INFINITE_TASK);
#endif
while(TRUE) {
#if WITH_Z_UNO_CODE
ApplicationPoll();
#endif
#if WITH_UART0
CheckUART();
#endif
#if WITH_SODA_UART
checkSodaUart();
#endif
#if WITH_BUTTONS
ParseButtonEvents();
ClearButtonEvents();
#endif
#if WITH_TASKER
if (tasker_flag == TRUE) {
tasker_flag = FALSE;
Tasker();
}
#endif
#if WITH_BINDER
EventBinder();
#endif
#if WITH_GENERAL_TESTING_FILE
generalTestingRoutine();
#endif
}
}
示例9: AngleVectors
CBotBackstabSched::CBotBackstabSched(edict_t *pEnemy)
{
Vector vrear;
Vector vangles;
AngleVectors(CBotGlobals::EntityEyeAngles(pEnemy), &vangles);
vrear = CBotGlobals::EntityOrigin(pEnemy) - (vangles * 45) + Vector(0, 0, 32);
AddTask(new CFindPathTask(vrear));
AddTask(new CBotBackstab(pEnemy));
}
示例10: main
int main(void)
{
DDRA = 0xFF;
//PORTA = 0b11111111; // AtMega 16
PORTA = 0b00000000;
AddTask(Set0, 1, 0);
AddTask(Set1, 2, 1);
AddTask(Set2, 3, 2);
AddTask(Set3, 4, 3);
schedule();
}
示例11: main
int main(void)
{
// Timer 0 w trybie OCR
TIMSK |= (1 << OCIE0); // COMP overflow
OCR0 = 250; // 250 * 64 = 16MHz = 1000 przerwañ na sekundê
TCCR0 |= (1 << CS00) | (1 << CS01); // Prescaller 64
sei();
AddTask(0, 1, &Led1, 0);
AddTask(1, 2, &Led2, 0);
AddTask(2, 3, &Led3, 0);
execute();
}
示例12: main
int main(int argc, char **argv)
{
int arg_ins=1;
float arg_exit=7;
if (0 != InitPool()) return 1;
AddTask(Task1, &arg_ins, NULL, &arg_exit);
AddTask(Task2, &arg_ins, NULL, &arg_exit);
while(1) {
SLEEP(10);
}
return 0;
}
示例13: ODWaveTrackTaskQueue
void ODManager::AddTaskToWaveTrack(ODTask* task, WaveTrack* track)
{
ODWaveTrackTaskQueue* queue = NULL;
mQueuesMutex.Lock();
for(int i=0;i<mQueues.size();i++)
{
if(mQueues[i]->ContainsWaveTrack(track))
queue=mQueues[i];
}
if(queue)
{
//Add it to the existing queue but keep the lock since this reference can be deleted.
queue->AddTask(task);
mQueuesMutex.Unlock();
}
else
{
//Make a new one, add it to the local track queue, and to the immediate running task list,
//since this task is definitely at the head
queue = new ODWaveTrackTaskQueue(track);
queue->AddTask(task);
mQueues.push_back(queue);
mQueuesMutex.Unlock();
AddTask(task);
}
}
示例14: AddTask
///remove tasks from ODWaveTrackTaskQueues that have been done. Schedules new ones if they exist
///Also remove queues that have become empty.
void ODManager::UpdateQueues()
{
mQueuesMutex.Lock();
for(int i=0;i<mQueues.size();i++)
{
if(mQueues[i]->IsFrontTaskComplete())
{
mQueues[i]->RemoveFrontTask();
//schedule next.
if(!mQueues[i]->IsEmpty())
{
//we need to release the lock on the queue vector before using the task vector's lock or we deadlock
//so get a temp.
ODWaveTrackTaskQueue* queue;
queue = mQueues[i];
mQueuesMutex.Unlock();
AddTask(queue->GetFrontTask());
mQueuesMutex.Lock();
}
}
//if the queue is empty delete it.
if(mQueues[i]->IsEmpty())
{
delete mQueues[i];
mQueues.erase(mQueues.begin()+i);
i--;
}
}
mQueuesMutex.Unlock();
}
示例15: PickupSimple
bool Scene_Inca_Passage::ObjectClicked(const char *szObjectName, float x, float y)
{
/* Cartouches */
if (strcmp(szObjectName, "inca_cartouche1_ground") == 0) {
PickupSimple(szObjectName, "inv_inca_cartouche1");
}
if (strcmp(szObjectName, "inca_cartouche2_ground") == 0) {
if (TaskResolved("task_inca_fillhole")) {
PickupSimple(szObjectName, "inv_inca_cartouche2");
}
else {
_lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_YUMANCO_HOLE"), "", true, false);
AddTask("task_inca_fillhole");
}
}
/* Artefacts */
if (strcmp(szObjectName, "inca_artefact3") == 0) {
PickupSimple(szObjectName, "inv_inca_artefact3");
ResolveTask("task_inca_getartefact3");
TestTaskArtefacts();
}
if (strcmp(szObjectName, "inca_artefact4") == 0) {
PickupSimple(szObjectName, "inv_inca_artefact4");
ResolveTask("task_inca_getartefact4");
TestTaskArtefacts();
}
return false;
}