MCPcopy Index your code
hub / github.com/F-Stack/f-stack / InitFrame

Method InitFrame

adapter/micro_thread/micro_thread.cpp:519–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517};
518
519bool MtFrame::InitFrame(LogAdapter* logadpt, int max_thread_num)
520{
521 if(logadpt == NULL){
522 _log_adpt = &def_log_adapt;
523 }else{
524 _log_adpt = logadpt;
525 }
526
527 if ((this->InitKqueue(max_thread_num) < 0) || !this->InitialPool(max_thread_num))
528 {
529 MTLOG_ERROR("Init epoll or thread pool failed");
530 this->Destroy();
531 return false;
532 }
533 if (_sleeplist.HeapResize(max_thread_num * 2) < 0)
534 {
535 MTLOG_ERROR("Init heap list failed");
536 this->Destroy();
537 return false;
538 }
539
540 _timer = new CTimerMng(max_thread_num * 2);
541 if (NULL == _timer)
542 {
543 MTLOG_ERROR("Init heap timer failed");
544 this->Destroy();
545 return false;
546 }
547
548 _daemon = AllocThread();
549 if (NULL == _daemon)
550 {
551 MTLOG_ERROR("Alloc daemon thread failed");
552 this->Destroy();
553 return false;
554 }
555 _daemon->SetType(MicroThread::DAEMON);
556 _daemon->SetState(MicroThread::RUNABLE);
557 _daemon->SetSartFunc(MtFrame::DaemonRun, this);
558
559 _primo = new MicroThread(MicroThread::PRIMORDIAL);
560 if (NULL == _primo)
561 {
562 MTLOG_ERROR("new _primo thread failed");
563 this->Destroy();
564 return false;
565 }
566 _primo->SetState(MicroThread::RUNNING);
567 SetActiveThread(_primo);
568
569 _last_clock = GetSystemMS();
570 TAILQ_INIT(&_iolist);
571 TAILQ_INIT(&_pend_list);
572
573 //SetHookFlag();
574
575 return true;
576

Callers 1

mt_init_frameFunction · 0.80

Calls 7

InitKqueueMethod · 0.80
InitialPoolMethod · 0.80
HeapResizeMethod · 0.80
SetTypeMethod · 0.80
SetStateMethod · 0.80
SetSartFuncMethod · 0.80
DestroyMethod · 0.45

Tested by

no test coverage detected