diff --git a/src/unix.rs b/src/unix.rs index 163cf10..3f87a6f 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -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), }