Skip to content

Commit 8590136

Browse files
authored
chore(cpu_timer): cleanup code and place cfg attr correctly (#595)
1 parent 173cad4 commit 8590136

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

crates/cpu_timer/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mod linux {
4242
#[repr(C)]
4343
#[derive(Clone, Default)]
4444
pub struct CPUAlarmVal {
45+
#[cfg(target_os = "linux")]
4546
pub cpu_alarms_tx: Arc<Mutex<Option<mpsc::UnboundedSender<()>>>>,
4647
}
4748

@@ -131,9 +132,12 @@ impl CPUTimer {
131132

132133
pub async fn set_channel(&self) -> mpsc::UnboundedReceiver<()> {
133134
let (tx, rx) = mpsc::unbounded_channel();
134-
let mut val = self.cpu_alarm_val.cpu_alarms_tx.lock().await;
135+
#[cfg(target_os = "linux")]
136+
{
137+
let mut val = self.cpu_alarm_val.cpu_alarms_tx.lock().await;
138+
*val = Some(tx);
139+
}
135140

136-
*val = Some(tx);
137141
rx
138142
}
139143

@@ -176,11 +180,6 @@ impl CPUTimer {
176180
log::error!("CPU timer: not enabled (need Linux)");
177181
Ok(Self {})
178182
}
179-
180-
#[cfg(not(target_os = "linux"))]
181-
pub fn reset(&self) -> Result<(), Error> {
182-
Ok(())
183-
}
184183
}
185184

186185
pub fn get_thread_time() -> Result<i64, Error> {

0 commit comments

Comments
 (0)