rtkit-client-rs/examples/make_realtime/main.rs
2024-11-22 21:20:05 +01:00

22 lines
818 B
Rust

use nix::unistd::gettid;
use std::thread;
// use rtkit_client_rs::::RTKitProxyBlocking;
use rtkit_client_rs::{make_current_thread_realtime, Error};
fn main() {
println!("Main tid: {}", gettid());
thread::spawn(important_thread).join().unwrap();
}
fn important_thread() {
println!("Important thread tid: {}", gettid());
let requested_priority = 40;
let actual_priority = make_current_thread_realtime(Some(requested_priority));
match actual_priority {
Ok(actual_priority) => println!("Requested priority: {}, Actual priority: {}", requested_priority, actual_priority),
Err(Error::PermissionDenied) => println!("Permission denied. Do you have polkit rules set up, or otherwise have the necessary permissions?"),
Err(e) => println!("Internal zbus error: {}", e),
}
}