mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Implement custom QoS-aware thread pool
This code replaces the thread pool implementation we were using previously (from the `threadpool` crate). By making the thread pool aware of QoS, each job spawned on the thread pool can have a different QoS class. This commit also replaces every QoS class used previously with Default as a temporary measure so that each usage can be chosen deliberately.
This commit is contained in:
parent
f6e3a87bf9
commit
2924fd2213
14 changed files with 184 additions and 93 deletions
|
@ -13,6 +13,9 @@
|
|||
|
||||
use std::fmt;
|
||||
|
||||
mod pool;
|
||||
pub use pool::Pool;
|
||||
|
||||
pub fn spawn<F, T>(qos_class: QoSClass, f: F) -> JoinHandle<T>
|
||||
where
|
||||
F: FnOnce() -> T,
|
||||
|
@ -152,6 +155,8 @@ pub enum QoSClass {
|
|||
/// performance, responsiveness and efficiency.
|
||||
Utility,
|
||||
|
||||
Default,
|
||||
|
||||
/// TLDR: tasks that block using your app
|
||||
///
|
||||
/// Contract:
|
||||
|
@ -229,6 +234,7 @@ mod imp {
|
|||
let c = match class {
|
||||
QoSClass::UserInteractive => libc::qos_class_t::QOS_CLASS_USER_INTERACTIVE,
|
||||
QoSClass::UserInitiated => libc::qos_class_t::QOS_CLASS_USER_INITIATED,
|
||||
QoSClass::Default => libc::qos_class_t::QOS_CLASS_DEFAULT,
|
||||
QoSClass::Utility => libc::qos_class_t::QOS_CLASS_UTILITY,
|
||||
QoSClass::Background => libc::qos_class_t::QOS_CLASS_BACKGROUND,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue