Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions crates/cpu_timer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod linux {
#[repr(C)]
#[derive(Clone, Default)]
pub struct CPUAlarmVal {
#[cfg(target_os = "linux")]
pub cpu_alarms_tx: Arc<Mutex<Option<mpsc::UnboundedSender<()>>>>,
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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<i64, Error> {
Expand Down
Loading