From 780d11926ad0044872a4a3cdd85e96537c5a493d Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Wed, 6 Oct 2021 16:06:08 -0600 Subject: [PATCH] metal flag guards temperature gauge --- appmgr/Cargo.toml | 3 ++- appmgr/src/system.rs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/appmgr/Cargo.toml b/appmgr/Cargo.toml index acf0c061d..0d322563a 100644 --- a/appmgr/Cargo.toml +++ b/appmgr/Cargo.toml @@ -38,7 +38,8 @@ path = "src/bin/embassy-cli.rs" [features] avahi = ["avahi-sys"] -default = ["avahi", "sound"] +default = ["avahi", "sound", "metal"] +metal = [] sound = [] [dependencies] diff --git a/appmgr/src/system.rs b/appmgr/src/system.rs index f86c8f490..1412b83df 100644 --- a/appmgr/src/system.rs +++ b/appmgr/src/system.rs @@ -1,6 +1,7 @@ use std::fmt; use futures::future::try_join_all; +use futures::FutureExt; use rpc_toolkit::command; use serde::ser::SerializeStruct; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -190,6 +191,7 @@ pub struct MetricsDisk { } #[derive(Deserialize, Serialize, Clone, Debug)] pub struct Metrics { + #[cfg(feature = "metal")] #[serde(rename = "General")] general: MetricsGeneral, #[serde(rename = "Memory")] @@ -284,6 +286,7 @@ pub async fn launch_metrics_task Receiver>>( } tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; } + #[cfg(feature = "metal")] { // lock for writing let mut guard = cache.write().await; @@ -298,6 +301,7 @@ pub async fn launch_metrics_task Receiver>>( }) } // launch persistent temp task + #[cfg(feature = "metal")] let temp_task = launch_temp_task(cache, mk_shutdown()); // launch persistent cpu task let cpu_task = launch_cpu_task(cache, proc_stat, mk_shutdown()); @@ -305,9 +309,19 @@ pub async fn launch_metrics_task Receiver>>( let mem_task = launch_mem_task(cache, mk_shutdown()); // launch persistent disk task let disk_task = launch_disk_task(cache, mk_shutdown()); - tokio::join!(temp_task, cpu_task, mem_task, disk_task,); + + let mut task_vec = Vec::new(); + task_vec.push(cpu_task.boxed()); + task_vec.push(mem_task.boxed()); + task_vec.push(disk_task.boxed()); + + #[cfg(feature = "metal")] + task_vec.push(temp_task.boxed()); + + futures::future::join_all(task_vec).await; } +#[cfg(feature = "metal")] async fn launch_temp_task( cache: &RwLock>, mut shutdown: Receiver>,