Skip to content

Commit

Permalink
Try fix macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
iddm committed Nov 14, 2023
1 parent dff33c6 commit 1d5cc10
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,26 @@ impl ThreadPriority {
};

match policy {
ThreadSchedulePolicy::Normal(NormalThreadSchedulePolicy::Idle) if IS_LINUX_ANDROID => {
// Only `0` can be returned for `Idle` threads on Linux/Android.
Ok(0)
}
ThreadSchedulePolicy::Normal(_) if IS_MACOS_IOS => {
// macOS/iOS allows specifying the priority using sched params.
get_edge_priority(policy)
}
ThreadSchedulePolicy::Normal(_) if IS_LINUX_ANDROID => {
// Niceness can be used on Linux/Android.
Ok(match edge {
PriorityPolicyEdgeValueType::Minimum => NICENESS_MIN as libc::c_int,
PriorityPolicyEdgeValueType::Maximum => NICENESS_MAX as libc::c_int,
})
}
ThreadSchedulePolicy::Normal(_) => {
Err(Error::Priority(
"Unsupported thread priority for this OS. Change the scheduling policy or use a supported OS.",
))
ThreadSchedulePolicy::Normal(normal) => {
if IS_LINUX_ANDROID {
if normal == NormalThreadSchedulePolicy::Idle {
// Only `0` can be returned for `Idle` threads on Linux/Android.
Ok(0)
} else {
// Niceness can be used on Linux/Android.
Ok(match edge {
PriorityPolicyEdgeValueType::Minimum => NICENESS_MIN as libc::c_int,
PriorityPolicyEdgeValueType::Maximum => NICENESS_MAX as libc::c_int,
})
}
} else if IS_MACOS_IOS {
// macOS/iOS allows specifying the priority using sched params.
get_edge_priority(policy)
} else {
Err(Error::Priority(
"Unsupported thread priority for this OS. Change the scheduling policy or use a supported OS.",
))
}
}
_ => get_edge_priority(policy),
}
Expand Down

0 comments on commit 1d5cc10

Please sign in to comment.