MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mt_exec_all_task

Function mt_exec_all_task

adapter/micro_thread/mt_api.cpp:501–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499};
500
501int mt_exec_all_task(IMtTaskList& req_list)
502{
503 MtFrame* mtframe = MtFrame::Instance();
504 MicroThread* thread = mtframe->GetActiveThread();
505 IMtTask* task = NULL;
506 MicroThread* sub = NULL;
507 MicroThread* tmp = NULL;
508 int rc = -1;
509
510 MicroThread::SubThreadList list;
511 TAILQ_INIT(&list);
512
513 if (0 == req_list.size())
514 {
515 MTLOG_DEBUG("no task for execult");
516 return 0;
517 }
518
519 for (IMtTaskList::iterator it = req_list.begin(); it != req_list.end(); ++it)
520 {
521 task = *it;
522 sub = MtFrame::CreateThread(mt_task_process, task, false);
523 if (NULL == sub)
524 {
525 MTLOG_ERROR("create sub thread failed");
526 goto EXIT_LABEL;
527 }
528
529 sub->SetType(MicroThread::SUB_THREAD);
530 TAILQ_INSERT_TAIL(&list, sub, _sub_entry);
531 }
532
533 TAILQ_FOREACH_SAFE(sub, &list, _sub_entry, tmp)
534 {
535 TAILQ_REMOVE(&list, sub, _sub_entry);
536 thread->AddSubThread(sub);
537 mtframe->InsertRunable(sub);
538 }
539
540 thread->Wait();
541 rc = 0;
542
543EXIT_LABEL:
544
545 TAILQ_FOREACH_SAFE(sub, &list, _sub_entry, tmp)
546 {
547 TAILQ_REMOVE(&list, sub, _sub_entry);
548 mtframe->FreeThread(sub);
549 }
550
551 return rc;
552
553}
554
555void mt_set_msg_private(void *data)
556{

Callers

nothing calls this directly

Calls 6

GetActiveThreadMethod · 0.80
SetTypeMethod · 0.80
AddSubThreadMethod · 0.80
InsertRunableMethod · 0.80
WaitMethod · 0.80
FreeThreadMethod · 0.80

Tested by

no test coverage detected