pub struct Cpu { /* private fields */ }Expand description
Accounts for time executing code on the native CPU, calculating a corresponding delay for when the simulated CPU should be allowed to run next.
Implementations§
Source§impl Cpu
 
impl Cpu
Sourcepub fn new(
    simulated_frequency: u64,
    native_frequency: u64,
    threshold: Option<SimulationTime>,
    precision: Option<SimulationTime>,
) -> Self
 
pub fn new( simulated_frequency: u64, native_frequency: u64, threshold: Option<SimulationTime>, precision: Option<SimulationTime>, ) -> Self
threshold: if None, never report a delay. Otherwise only report a
delay after it is more than this threshold.
precision: if provided, round individual native delays to this
granularity (rounding up at midpoint). Panics if this is Some(0).
Sourcepub fn update_time(&mut self, now: EmulatedTime)
 
pub fn update_time(&mut self, now: EmulatedTime)
Configure the current time.
Sourcepub fn add_delay(&mut self, native_delay: Duration)
 
pub fn add_delay(&mut self, native_delay: Duration)
Account for native_delay spent natively executing code.
Sourcepub fn delay(&self) -> SimulationTime
 
pub fn delay(&self) -> SimulationTime
Calculate the simulated delay until this CPU is ready to run again.
Auto Trait Implementations§
impl Freeze for Cpu
impl RefUnwindSafe for Cpu
impl Send for Cpu
impl Sync for Cpu
impl Unpin for Cpu
impl UnwindSafe for Cpu
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
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more