MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / createSecondaryThread

Method createSecondaryThread

src/UtilsCtrl/ThreadPool/UThreadPool.cpp:226–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224
225
226CStatus UThreadPool::createSecondaryThread(const CInt size) {
227 CGRAPH_FUNCTION_BEGIN
228
229 const int leftSize = static_cast<int>(config_.max_thread_size_ - config_.default_thread_size_ - secondary_threads_.size());
230 const int realSize = std::min(size, leftSize); // 使用 realSize 来确保所有的线程数量之和,不会超过设定max值
231
232 CGRAPH_LOCK_GUARD lock(st_mutex_);
233 for (int i = 0; i < realSize; i++) {
234 auto ptr = CGRAPH_MAKE_UNIQUE_COBJECT(UThreadSecondary)
235 ptr->setThreadPoolInfo(&task_queue_, &priority_task_queue_, &config_);
236 status += ptr->init();
237 secondary_threads_.emplace_back(std::move(ptr));
238 }
239
240 CGRAPH_FUNCTION_END
241}
242
243
244CVoid UThreadPool::monitor() {

Callers

nothing calls this directly

Calls 1

initMethod · 0.45

Tested by

no test coverage detected