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

Method createSecondaryThread

src/UtilsCtrl/ThreadPool/UThreadPool.cpp:157–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156
157CStatus 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
173CVoid UThreadPool::monitor() {

Callers

nothing calls this directly

Calls 1

initMethod · 0.80

Tested by

no test coverage detected