* 设置线程优先级,仅针对非windows平台使用 */
| 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), ¶m); |
| 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系统 |
no test coverage detected