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

Method dispatch

src/UtilsCtrl/ThreadPool/UThreadPool.cpp:209–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209CIndex UThreadPool::dispatch(const CIndex origIndex) {
210 CIndex realIndex = 0;
211 if (CGRAPH_DEFAULT_TASK_STRATEGY == origIndex) {
212 realIndex = cur_index_.fetch_add(1, std::memory_order_relaxed) % config_.max_thread_size_;
213 if (realIndex >= 0 && realIndex < config_.default_thread_size_
214 && primary_threads_[realIndex]->is_running_) {
215 // 如果是默认调度,并且被放置到 正在running 的pt中,则切换为 trigger_one 的策略,防止阻塞
216 realIndex = CGRAPH_TRIGGER_ALL_THREAD_STRATEGY;
217 }
218 } else {
219 realIndex = origIndex;
220 }
221
222 return realIndex; // 交到上游去判断,走哪个线程
223}
224
225
226CStatus UThreadPool::createSecondaryThread(const CInt size) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected