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

Method InitialPool

adapter/micro_thread/micro_thread.cpp:387–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385unsigned int ThreadPool::default_stack_size = DEFAULT_STACK_SIZE; ///< 128k stack.
386
387bool ThreadPool::InitialPool(int max_num)
388{
389 MicroThread *thread = NULL;
390 for (unsigned int i = 0; i < default_thread_num; i++)
391 {
392 thread = new MicroThread();
393 if ((NULL == thread) || (false == thread->Initial()))
394 {
395 MTLOG_ERROR("init pool, thread %p init failed", thread);
396 if (thread) delete thread;
397 continue;
398 }
399 thread->SetFlag(MicroThread::FREE_LIST);
400 _freelist.push(thread);
401 }
402
403 _total_num = _freelist.size();
404 _max_num = max_num;
405 _use_num = 0;
406 if (_total_num <= 0)
407 {
408 return false;
409 }
410 else
411 {
412 return true;
413 }
414}
415
416void ThreadPool::DestroyPool()
417{

Callers 1

InitFrameMethod · 0.80

Calls 2

InitialMethod · 0.80
SetFlagMethod · 0.80

Tested by

no test coverage detected