running parallel tokio tasks for heartbeat and metrics
This commit is contained in:
@@ -11,7 +11,7 @@ pub struct CpuInfo {
|
||||
pub current_temp: Option<f64>,
|
||||
}
|
||||
|
||||
pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error>> {
|
||||
pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error + Send + Sync>> {
|
||||
let mut sys = System::new();
|
||||
sys.refresh_cpu_all();
|
||||
|
||||
@@ -28,13 +28,13 @@ pub async fn get_cpu_info() -> Result<CpuInfo, Box<dyn Error>> {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_cpu_load(sys: &mut System) -> Result<f64, Box<dyn Error>> {
|
||||
pub async fn get_cpu_load(sys: &mut System) -> Result<f64, Box<dyn Error + Send + Sync>> {
|
||||
sys.refresh_cpu_all();
|
||||
tokio::task::yield_now().await; // Allow other tasks to run
|
||||
Ok(sys.global_cpu_usage() as f64)
|
||||
}
|
||||
|
||||
pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
|
||||
pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error + Send + Sync>> {
|
||||
println!("Attempting to get CPU temperature...");
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
|
Reference in New Issue
Block a user