• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ AddTask函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AddTask函数的典型用法代码示例。如果您正苦于以下问题:C++ AddTask函数的具体用法?C++ AddTask怎么用?C++ AddTask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AddTask函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CFindPathTask

CBotTF2HealSched::CBotTF2HealSched(edict_t *pHeal)
{
	CFindPathTask *findpath = new CFindPathTask(pHeal);
	findpath->SetCompleteInterrupt(CONDITION_SEE_HEAL);
	AddTask(findpath);
	AddTask(new CBotTF2MedicHeal());
}
开发者ID:Deathreus,项目名称:AFKBot,代码行数:7,代码来源:bot_schedule.cpp


示例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);
   }
}
开发者ID:henricj,项目名称:audacity,代码行数:39,代码来源:ODManager.cpp


示例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;       //из расчета кол-ва тиков выполняемой функции и частоты прерывания таймера
   }
}
开发者ID:4glk,项目名称:at8_ct,代码行数:25,代码来源:dispatch.c


示例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();
}
开发者ID:Deathreus,项目名称:AFKBot,代码行数:32,代码来源:bot_schedule.cpp


示例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
}
开发者ID:Deathreus,项目名称:AFKBot,代码行数:8,代码来源:bot_schedule.cpp


示例6: DS18B20InitializeSensorTask

void DS18B20InitializeSensorTask() {
    DS18B20InitializeSensorAction();
    if (DS18B20ResultInitializeSensor == DS18B20OperationOK) {
        AddTask(DS18B20ConvertTemperatureTask, DS18B20ConvertTemperatureTaskDelay);
    }
    else {
        AddTask(DS18B20InitializeSensorTask, DS18B20RepeatInitializeSensorTaskDelay);
    }
}
开发者ID:Wierus,项目名称:WaterThermostat,代码行数:9,代码来源:DS18B20Tasks.c


示例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();
}
开发者ID:Yurrili,项目名称:US,代码行数:9,代码来源:GccApplication1.c


示例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
		}
}
开发者ID:NilsBohr,项目名称:MCU_Testing_Kit,代码行数:57,代码来源:main.c


示例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));
}
开发者ID:Deathreus,项目名称:AFKBot,代码行数:11,代码来源:bot_schedule.cpp


示例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();
}
开发者ID:nicglu,项目名称:Uklady_sterujace,代码行数:13,代码来源:cw5.1.c


示例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();
}
开发者ID:ShadowDancer,项目名称:uklady_sterowania,代码行数:15,代码来源:main.c


示例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;
}
开发者ID:ipodipad,项目名称:scripts,代码行数:16,代码来源:test.c


示例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);
      
   }
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:31,代码来源:ODManager.cpp


示例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();
   
   
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:37,代码来源:ODManager.cpp


示例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;
}
开发者ID:CortlandNation9,项目名称:Gamecodeur,代码行数:29,代码来源:Scene_Inca_Passage.cpp


示例16: Task

void Scheduler::CreateTask(TaskF const& fn)
{
    Task* tk = new Task(fn, GetOptions().stack_size);
    ++task_count_;
    ++runnale_task_count_;
    AddTask(tk);
}
开发者ID:nevermore22,项目名称:cpp_features,代码行数:7,代码来源:scheduler.cpp


示例17: AddTask

void ThreadPool::AddTask(Closure<void()>* callback) {
    // The memory address is random enough for load balance, but need
    // remove low alignment part. (The lowest 5 bits of allocated object
    // address are always 0 for 64 bit system).
    unsigned int dispatch_key = reinterpret_cast<uintptr_t>(callback) / 32;
    AddTask(callback, dispatch_key);
}
开发者ID:343829084,项目名称:toft,代码行数:7,代码来源:thread_pool.cpp



注:本文中的AddTask函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AddText函数代码示例发布时间:2022-05-30
下一篇:
C++ AddTail函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap