| 48 | |
| 49 | |
| 50 | CStatus UThreadPool::init() { |
| 51 | CGRAPH_FUNCTION_BEGIN |
| 52 | if (is_init_) { |
| 53 | CGRAPH_FUNCTION_END |
| 54 | } |
| 55 | |
| 56 | primary_threads_.reserve(config_.default_thread_size_); |
| 57 | for (int i = 0; i < config_.default_thread_size_; i++) { |
| 58 | auto ptr = CGRAPH_SAFE_MALLOC_COBJECT(UThreadPrimary) // 创建核心线程数 |
| 59 | |
| 60 | ptr->setThreadPoolInfo(i, &task_queue_, &primary_threads_, &config_); |
| 61 | status += ptr->init(); |
| 62 | primary_threads_.emplace_back(ptr); |
| 63 | } |
| 64 | CGRAPH_FUNCTION_CHECK_STATUS |
| 65 | |
| 66 | is_init_ = true; |
| 67 | CGRAPH_FUNCTION_END |
| 68 | } |
| 69 | |
| 70 | |
| 71 | CStatus UThreadPool::submit(const UTaskGroup& taskGroup, CMSec ttl) { |
no outgoing calls
no test coverage detected