@@ -62,8 +62,7 @@ impl Builder {
62
62
63
63
pub struct JoinHandle < T = ( ) > {
64
64
// `inner` is an `Option` so that we can
65
- // take ownership of the contained `JoinHandle`
66
- // in the `Drop` impl below.
65
+ // take ownership of the contained `JoinHandle`.
67
66
inner : Option < jod_thread:: JoinHandle < T > > ,
68
67
allow_leak : bool ,
69
68
}
@@ -93,8 +92,8 @@ impl<T> fmt::Debug for JoinHandle<T> {
93
92
}
94
93
95
94
#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
95
+ // Please maintain order from least to most priority for the derived `Ord` impl.
96
96
pub enum QoSClass {
97
- // Maintain order in priority from least to most.
98
97
Background ,
99
98
Utility ,
100
99
UserInitiated ,
@@ -132,9 +131,8 @@ pub fn set_current_thread_qos_class(class: QoSClass) {
132
131
// due to a previous call to a function such as `pthread_setschedparam`
133
132
// which is incompatible with QoS.
134
133
//
135
- // Let’s just panic here because rust-analyzer as a system
136
- // should have the property that QoS is used consistently
137
- // instead of old manual scheduling management APIs.
134
+ // Panic instead of returning an error
135
+ // to maintain the invariant that we only use QoS APIs.
138
136
panic ! ( "tried to set QoS of thread which has opted out of QoS (os error {errno})" )
139
137
}
140
138
@@ -187,8 +185,14 @@ pub fn get_current_thread_qos_class() -> Option<QoSClass> {
187
185
libc:: qos_class_t:: QOS_CLASS_DEFAULT => None , // QoS has never been set
188
186
libc:: qos_class_t:: QOS_CLASS_UTILITY => Some ( QoSClass :: Utility ) ,
189
187
libc:: qos_class_t:: QOS_CLASS_BACKGROUND => Some ( QoSClass :: Background ) ,
188
+
190
189
libc:: qos_class_t:: QOS_CLASS_UNSPECIFIED => {
191
- // We panic here because rust-analyzer should never use
190
+ // Using manual scheduling APIs causes threads to “opt out” of QoS.
191
+ // At this point they become incompatible with QoS,
192
+ // and as such have the “unspecified” QoS class.
193
+ //
194
+ // Panic instead of returning an error
195
+ // to maintain the invariant that we only use QoS APIs.
192
196
panic ! ( "tried to get QoS of thread which has opted out of QoS" )
193
197
}
194
198
}
0 commit comments