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

Method dispatch

src/UtilsCtrl/ThreadPool/UThreadPool.cpp:134–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132
133
134CIndex 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
157CStatus UThreadPool::createSecondaryThread(CInt size) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected