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

Method FreeThread

adapter/micro_thread/micro_thread.cpp:476–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

474}
475
476void ThreadPool::FreeThread(MicroThread* thread)
477{
478 ASSERT(!thread->HasFlag(MicroThread::FREE_LIST));
479 thread->Reset();
480 _use_num--;
481 _freelist.push(thread);
482 thread->SetFlag(MicroThread::FREE_LIST);
483
484 unsigned int free_num = _freelist.size();
485 if ((free_num > default_thread_num) && (free_num > 1))
486 {
487 thread = _freelist.front();
488 _freelist.pop();
489 thread->Destroy();
490 delete thread;
491 _total_num--;
492 if(default_thread_num / 2 >= DEFAULT_THREAD_NUM){
493 last_default_thread_num = default_thread_num;
494 default_thread_num = default_thread_num / 2;
495 }
496 }
497}
498
499int ThreadPool::GetUsedNum(void)
500{

Callers 2

ScheduleReclaimMethod · 0.80
mt_exec_all_taskFunction · 0.80

Calls 4

HasFlagMethod · 0.80
SetFlagMethod · 0.80
ResetMethod · 0.45
DestroyMethod · 0.45

Tested by

no test coverage detected