加个设置高优先级
This commit is contained in:
parent
d131daed4e
commit
bc7e5edfc4
@ -214,6 +214,7 @@ pub fn schdule_threads(cli_arg: Command, out_path: PathBuf) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
// 如果不是, 则发送一个对应线程 id 的消息
|
// 如果不是, 则发送一个对应线程 id 的消息
|
||||||
let _ = work_sender.send(Some((latest_speed.0, shared_status.top_id..shared_status.top_id + batch)));
|
let _ = work_sender.send(Some((latest_speed.0, shared_status.top_id..shared_status.top_id + batch)));
|
||||||
@ -247,6 +248,7 @@ pub fn schdule_threads(cli_arg: Command, out_path: PathBuf) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
// 如果没有结束, 则发送一个 batch
|
// 如果没有结束, 则发送一个 batch
|
||||||
let _ = work_sender.send(Some((
|
let _ = work_sender.send(Some((
|
||||||
|
@ -123,6 +123,23 @@ pub fn set_process_cores(cores: usize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_process_priority_to_high() {
|
||||||
|
#[cfg(windows)]
|
||||||
|
unsafe {
|
||||||
|
use windows_sys::Win32::System::Threading::HIGH_PRIORITY_CLASS;
|
||||||
|
use windows_sys::Win32::System::Threading::{GetCurrentProcess, SetPriorityClass};
|
||||||
|
let process = GetCurrentProcess();
|
||||||
|
match SetPriorityClass(process, HIGH_PRIORITY_CLASS) {
|
||||||
|
0 => warn!("设置进程优先级为高失败 {}", std::io::Error::last_os_error()),
|
||||||
|
_ => info!("设置进程优先级为高成功"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
warn!("Linux 下不支持设置进程优先级为高 (未实现)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut cli_arg = Command::parse();
|
let mut cli_arg = Command::parse();
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
@ -160,6 +177,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!("{}", cli_arg.display_info());
|
info!("{}", cli_arg.display_info());
|
||||||
|
set_process_priority_to_high();
|
||||||
cacluate::start_main(cli_arg, out_path);
|
cacluate::start_main(cli_arg, out_path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user