pub struct Timer<R: Rate>(/* private fields */);Expand description
A running timer, and the scope its timestamps belong to.
stop takes it by value, so a timestamp taken from it keeps
the count running for as long as it is held.
Implementations§
Source§impl<R: Rate> Timer<R>
impl<R: Rate> Timer<R>
Sourcepub unsafe fn start(_rate: R) -> Option<Self>
pub unsafe fn start(_rate: R) -> Option<Self>
Start counting at R, or None if the timer is already running.
Writing the control register can advance the timer once, so the first interrupt may come early.
§Safety
Lets the timer interrupt through and turns interrupts on. That is preemption, which the surrounding code may have been written to rule out, and it happens whether or not a timer is handed back.
Sourcepub fn wait(&self, span: Duration<R>)
pub fn wait(&self, span: Duration<R>)
Sleep until span has passed.
The CPU sleeps while waiting, so this does not return if IE lacks
TIMER or interrupts are off: the count only moves when the handler
runs.
Trait Implementations§
Auto Trait Implementations§
impl<R> BankSafe for Timer<R>where
R: BankSafe,
impl<R> Freeze for Timer<R>
impl<R> RefUnwindSafe for Timer<R>where
R: RefUnwindSafe,
impl<R> Unpin for Timer<R>where
R: Unpin,
impl<R> UnsafeUnpin for Timer<R>
impl<R> UnwindSafe for Timer<R>where
R: 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