| 155 | |
| 156 | |
| 157 | CStatus UThreadPool::createSecondaryThread(CInt size) { |
| 158 | CGRAPH_FUNCTION_BEGIN |
| 159 | |
| 160 | int leftSize = (int)(config_.max_thread_size_ - config_.default_thread_size_ - secondary_threads_.size()); |
| 161 | int realSize = std::min(size, leftSize); // 使用 realSize 来确保所有的线程数量之和,不会超过设定max值 |
| 162 | for (int i = 0; i < realSize; i++) { |
| 163 | auto ptr = CGRAPH_MAKE_UNIQUE_COBJECT(UThreadSecondary) |
| 164 | ptr->setThreadPoolInfo(&task_queue_, &priority_task_queue_, &config_); |
| 165 | status += ptr->init(); |
| 166 | secondary_threads_.emplace_back(std::move(ptr)); |
| 167 | } |
| 168 | |
| 169 | CGRAPH_FUNCTION_END |
| 170 | } |
| 171 | |
| 172 | |
| 173 | CVoid UThreadPool::monitor() { |