Skip to content

Commit b77ec38

Browse files
author
Sangho Lee
committed
rebase
1 parent 62131ec commit b77ec38

File tree

1 file changed

+8
-0
lines changed
  • litebox_platform_kernel/src

1 file changed

+8
-0
lines changed

litebox_platform_kernel/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ impl DebugLogProvider for LiteBoxKernel {
223223
}
224224

225225
/// An implementation of [`litebox::platform::Instant`]
226+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
226227
pub struct Instant(u64);
227228

228229
/// An implementation of [`litebox::platform::SystemTime`]
@@ -249,6 +250,13 @@ impl litebox::platform::Instant for Instant {
249250
)
250251
})
251252
}
253+
254+
fn checked_add(&self, duration: core::time::Duration) -> Option<Self> {
255+
let duration_micros: u64 = duration.as_micros().try_into().ok()?;
256+
Some(Instant(self.0.checked_add(
257+
duration_micros.checked_mul(CPU_MHZ.load(core::sync::atomic::Ordering::Relaxed))?,
258+
)?))
259+
}
252260
}
253261

254262
impl Instant {

0 commit comments

Comments
 (0)