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

Function setSchedParam

src/UtilsCtrl/ThreadPool/Thread/UThreadBase.h:126–145  ·  view source on GitHub ↗

* 设置线程优先级,仅针对非windows平台使用 */

Source from the content-addressed store, hash-verified

124 * 设置线程优先级,仅针对非windows平台使用
125 */
126 CVoid setSchedParam() {
127#ifndef _WIN32
128 int priority = CGRAPH_THREAD_SCHED_OTHER;
129 int policy = CGRAPH_THREAD_MIN_PRIORITY;
130 if (type_ == CGRAPH_THREAD_TYPE_PRIMARY) {
131 priority = config_->primary_thread_priority_;
132 policy = config_->primary_thread_policy_;
133 } else if (type_ == CGRAPH_THREAD_TYPE_SECONDARY) {
134 priority = config_->secondary_thread_priority_;
135 policy = config_->secondary_thread_policy_;
136 }
137
138 auto handle = thread_.native_handle();
139 sched_param param = { calcPriority(priority) };
140 int ret = pthread_setschedparam(handle, calcPolicy(policy), &param);
141 if (0 != ret) {
142 CGRAPH_ECHO("warning : set thread sched param failed, error code is [%d]", ret);
143 }
144#endif
145 }
146
147 /**
148 * 设置线程亲和性,仅针对linux系统

Callers 2

UThreadSecondary.hFile · 0.85
initFunction · 0.85

Calls 2

calcPriorityFunction · 0.85
CGRAPH_ECHOFunction · 0.85

Tested by

no test coverage detected