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 {