| 207 | |
| 208 | |
| 209 | CIndex 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 | |
| 226 | CStatus UThreadPool::createSecondaryThread(const CInt size) { |
nothing calls this directly
no outgoing calls
no test coverage detected