running_process_platform_internal/semantic_priority.rs
1//! Portable scheduling intent mapped by the native substrate.
2
3/// Scheduling intent for a newly created child.
4#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
5pub enum ProcessPriority {
6 /// Leave the host default/inherited priority unchanged.
7 #[default]
8 Normal,
9 /// Below-normal scheduling.
10 Low,
11 /// Idle scheduling.
12 Idle,
13 /// Elevated scheduling. Host permissions still apply.
14 High,
15}
16
17impl ProcessPriority {
18 /// Return the native niceness value representing this portable intent.
19 #[must_use]
20 pub fn nice_value(self) -> Option<i32> {
21 match self {
22 Self::Normal => None,
23 Self::Idle => Some(19),
24 Self::Low => Some(if cfg!(windows) { 1 } else { 10 }),
25 Self::High => Some(if cfg!(windows) { -15 } else { -5 }),
26 }
27 }
28}