From 003790ca2d9aa1734d8486215792c7fe2fcdfabd Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Fri, 22 Aug 2025 04:33:05 +0000 Subject: [PATCH] chore(cpu_timer): cleanup code and place cfg attr correctly --- crates/cpu_timer/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/cpu_timer/src/lib.rs b/crates/cpu_timer/src/lib.rs index 0be14d5e5..7762362e7 100644 --- a/crates/cpu_timer/src/lib.rs +++ b/crates/cpu_timer/src/lib.rs @@ -42,6 +42,7 @@ mod linux { #[repr(C)] #[derive(Clone, Default)] pub struct CPUAlarmVal { + #[cfg(target_os = "linux")] pub cpu_alarms_tx: Arc>>>, } @@ -131,9 +132,12 @@ impl CPUTimer { pub async fn set_channel(&self) -> mpsc::UnboundedReceiver<()> { let (tx, rx) = mpsc::unbounded_channel(); - let mut val = self.cpu_alarm_val.cpu_alarms_tx.lock().await; + #[cfg(target_os = "linux")] + { + let mut val = self.cpu_alarm_val.cpu_alarms_tx.lock().await; + *val = Some(tx); + } - *val = Some(tx); rx } @@ -176,11 +180,6 @@ impl CPUTimer { log::error!("CPU timer: not enabled (need Linux)"); Ok(Self {}) } - - #[cfg(not(target_os = "linux"))] - pub fn reset(&self) -> Result<(), Error> { - Ok(()) - } } pub fn get_thread_time() -> Result {