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

Function fatWait

src/UtilsCtrl/ThreadPool/Thread/UThreadPrimary.h:116–125  ·  view source on GitHub ↗

* 如果总是进入无task的状态,则开始休眠 * 休眠一定时间后,然后恢复执行状态,避免出现异常情况导致无法唤醒 */

Source from the content-addressed store, hash-verified

114 * 休眠一定时间后,然后恢复执行状态,避免出现异常情况导致无法唤醒
115 */
116 CVoid fatWait() {
117 ++cur_empty_epoch_;
118 CGRAPH_YIELD();
119 if (cur_empty_epoch_ >= config_->primary_thread_busy_epoch_) {
120 CGRAPH_UNIQUE_LOCK lk(mutex_);
121 cv_.wait_for(lk, std::chrono::milliseconds(config_->primary_thread_empty_interval_),
122 [this] { return 0 == cur_empty_epoch_ || !wsq_.isEmpty() || !pool_task_queue_->empty() || !done_; });
123 cur_empty_epoch_ = 0;
124 }
125 }
126
127
128 /**

Callers 3

commonRunAllMethod · 0.85
processTaskFunction · 0.85
processTasksFunction · 0.85

Calls 1

CGRAPH_YIELDFunction · 0.85

Tested by

no test coverage detected