Skip to content

Commit

Permalink
Implement setThreadPriority for Apple devices (#8200)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado authored Oct 16, 2024
1 parent 22db1be commit e8f3fc5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libs/utils/src/JobSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ void JobSystem::setThreadPriority(Priority priority) noexcept {
slog.w << "setpriority failed: " << strerror(errno) << io::endl;
}
#endif
#elif defined(__APPLE__)
qos_class_t qosClass = QOS_CLASS_DEFAULT;
switch (priority) {
case Priority::BACKGROUND:
qosClass = QOS_CLASS_BACKGROUND;
break;
case Priority::NORMAL:
qosClass = QOS_CLASS_DEFAULT;
break;
case Priority::DISPLAY:
qosClass = QOS_CLASS_USER_INTERACTIVE;
break;
case Priority::URGENT_DISPLAY:
qosClass = QOS_CLASS_USER_INTERACTIVE;
break;
}
errno = 0;
UTILS_UNUSED_IN_RELEASE int error;
error = pthread_set_qos_class_self_np(qosClass, 0);
#ifndef NDEBUG
if (UTILS_UNLIKELY(error)) {
slog.w << "pthread_set_qos_class_self_np failed: " << strerror(errno) << io::endl;
}
#endif
#endif
}

Expand Down

0 comments on commit e8f3fc5

Please sign in to comment.