| 132 | |
| 133 | |
| 134 | CIndex UThreadPool::dispatch(CIndex origIndex) { |
| 135 | if (unlikely(config_.fair_lock_enable_)) { |
| 136 | return CGRAPH_DEFAULT_TASK_STRATEGY; // 如果开启fair lock,则全部写入 pool的queue中,依次执行 |
| 137 | } |
| 138 | |
| 139 | CIndex realIndex = 0; |
| 140 | if (CGRAPH_DEFAULT_TASK_STRATEGY == origIndex) { |
| 141 | /** |
| 142 | * 如果是默认策略信息,在[0, default_thread_size_) 之间的,通过 thread 中queue来调度 |
| 143 | * 在[default_thread_size_, max_thread_size_) 之间的,通过 pool 中的queue来调度 |
| 144 | */ |
| 145 | realIndex = cur_index_++; |
| 146 | if (cur_index_ >= config_.max_thread_size_ || cur_index_ < 0) { |
| 147 | cur_index_ = 0; |
| 148 | } |
| 149 | } else { |
| 150 | realIndex = origIndex; |
| 151 | } |
| 152 | |
| 153 | return realIndex; // 交到上游去判断,走哪个线程 |
| 154 | } |
| 155 | |
| 156 | |
| 157 | CStatus UThreadPool::createSecondaryThread(CInt size) { |
nothing calls this directly
no outgoing calls
no test coverage detected