pub struct Tick<W>where
W: TickWidth,{ /* private fields */ }Expand description
A tick count of width W: monotonic since scheduler start, wrapping at
W::MAX exactly as the C kernel’s xTickCount does.
Stored as a u64 masked to the width, so the same code path serves every
width and every arithmetic test can be run at all three on the host.
Implementations§
Source§impl<W> Tick<W>where
W: TickWidth,
impl<W> Tick<W>where
W: TickWidth,
Sourcepub const fn new(raw: u64) -> Tick<W>
pub const fn new(raw: u64) -> Tick<W>
A count, masked to the width (a value above W::MAX wraps).
Sourcepub const fn wrapping_add(self, n: u64) -> Tick<W>
pub const fn wrapping_add(self, n: u64) -> Tick<W>
self + n, wrapping at the width (the tick interrupt’s increment).
Sourcepub const fn wrapping_sub(self, n: u64) -> Tick<W>
pub const fn wrapping_sub(self, n: u64) -> Tick<W>
self - n, wrapping at the width.
Sourcepub const fn checked_add(self, n: u64) -> Option<Tick<W>>
pub const fn checked_add(self, n: u64) -> Option<Tick<W>>
self + n, or None if the result would wrap. Blocking APIs use this
to know whether a wake time lands in the overflow delayed list.
Sourcepub const fn since(self, earlier: Tick<W>) -> u64
pub const fn since(self, earlier: Tick<W>) -> u64
Ticks elapsed from earlier to self, wrapping (the C kernel’s
xTickCount - xTimeOnEntering idiom).
Sourcepub const fn overflows_by(self, n: u64) -> bool
pub const fn overflows_by(self, n: u64) -> bool
Whether adding n to self crosses the wrap point (the wake time
belongs in the overflow delayed list).
Trait Implementations§
impl<W> Copy for Tick<W>
impl<W> Eq for Tick<W>
Source§impl<W> Ord for Tick<W>
impl<W> Ord for Tick<W>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<W> PartialOrd for Tick<W>where
W: PartialOrd + TickWidth,
impl<W> PartialOrd for Tick<W>where
W: PartialOrd + TickWidth,
impl<W> StructuralPartialEq for Tick<W>
Auto Trait Implementations§
impl<W> Freeze for Tick<W>where
PhantomData<W>: Freeze,
impl<W> RefUnwindSafe for Tick<W>where
PhantomData<W>: RefUnwindSafe,
impl<W> Send for Tick<W>where
PhantomData<W>: Send,
impl<W> Sync for Tick<W>where
PhantomData<W>: Sync,
impl<W> Unpin for Tick<W>where
PhantomData<W>: Unpin,
impl<W> UnsafeUnpin for Tick<W>where
PhantomData<W>: UnsafeUnpin,
impl<W> UnwindSafe for Tick<W>where
PhantomData<W>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more