1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Querying what the priority ladder can actually deliver right now.
//!
//! On Windows and macOS all seven [`ThreadPriority`] levels are always
//! distinct. On Linux, negative nice needs privilege - without it (and
//! without rtkit) `AboveNormal`, `Highest` and `TimeCritical` all resolve to
//! `nice(0)`, i.e. `Normal`. [`priority_capabilities`] predicts the outcome
//! so an engine can pick its threading strategy up front instead of
//! discovering the collapse from frame times.
use crateThreadPriority;
/// What each [`ThreadPriority`] level will effectively deliver, as opaque
/// ranks. Returned by [`priority_capabilities`].
///
/// `effective_rank[level as usize]` grows with effective strength; the
/// absolute numbers carry no meaning beyond ordering. Two levels with equal
/// rank currently resolve to the same scheduler behavior.
///
/// The snapshot is point-in-time: it reflects this process's rlimits and the
/// reachability of the system's priority broker (rtkit) at the moment of the
/// call. rtkit in particular can silently withdraw cooperation later (its
/// watchdog demotes a process that starves the canary), so treat the result
/// as a planning hint, not a contract.
/// Predicts what each [`ThreadPriority`] level will resolve to under this
/// process's current privileges. Touches no thread state.
///
/// Linux: computed from `RLIMIT_NICE` plus the rtkit daemon's `MinNiceLevel`
/// when the daemon is reachable (feature `rtkit`). Windows and macOS: all
/// seven levels are always distinct.
///
/// ```
/// use gdt_cpus::{ThreadPriority, priority_capabilities};
///
/// let caps = priority_capabilities();
/// if !caps.distinct(ThreadPriority::Highest, ThreadPriority::Normal) {
/// eprintln!("priority is flat here - consider promote_thread_to_realtime() for the audio feeder");
/// }
/// ```