Struct spin_sleep::SpinSleeper
source · [−]pub struct SpinSleeper { /* private fields */ }
Expand description
Accuracy container for spin sleeping. See crate docs.
Implementations
sourceimpl SpinSleeper
impl SpinSleeper
sourcepub fn new(native_accuracy_ns: SubsecondNanoseconds) -> SpinSleeper
pub fn new(native_accuracy_ns: SubsecondNanoseconds) -> SpinSleeper
Constructs new SpinSleeper with the input native sleep accuracy.
The lower the native_accuracy_ns
the more we effectively trust the accuracy of the
native_sleep
function.
sourcepub fn native_accuracy_ns(self) -> SubsecondNanoseconds
pub fn native_accuracy_ns(self) -> SubsecondNanoseconds
Returns configured native_accuracy_ns.
sourcepub fn spin_strategy(self) -> SpinStrategy
pub fn spin_strategy(self) -> SpinStrategy
Returns configured spin strategy.
sourcepub fn with_spin_strategy(self, strategy: SpinStrategy) -> Self
pub fn with_spin_strategy(self, strategy: SpinStrategy) -> Self
Returns a spin sleeper with the given SpinStrategy
.
Example
use spin_sleep::{SpinSleeper, SpinStrategy};
let sleeper = SpinSleeper::default().with_spin_strategy(SpinStrategy::SpinLoopHint);
sourcepub fn sleep(self, duration: Duration)
pub fn sleep(self, duration: Duration)
Puts the current thread to sleep for the duration less the configured native accuracy. Then spins until the specified duration has elapsed.
sourcepub fn sleep_s(self, seconds: Seconds)
pub fn sleep_s(self, seconds: Seconds)
Puts the current thread to sleep for the give seconds-duration less the configured native accuracy. Then spins until the specified duration has elapsed.
sourcepub fn sleep_ns(self, nanoseconds: Nanoseconds)
pub fn sleep_ns(self, nanoseconds: Nanoseconds)
Puts the current thread to sleep for the give nanoseconds-duration less the configured native accuracy. Then spins until the specified duration has elapsed.
Trait Implementations
sourceimpl Clone for SpinSleeper
impl Clone for SpinSleeper
sourcefn clone(&self) -> SpinSleeper
fn clone(&self) -> SpinSleeper
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SpinSleeper
impl Debug for SpinSleeper
sourceimpl Default for SpinSleeper
impl Default for SpinSleeper
sourceimpl Hash for SpinSleeper
impl Hash for SpinSleeper
sourceimpl PartialEq<SpinSleeper> for SpinSleeper
impl PartialEq<SpinSleeper> for SpinSleeper
sourcefn eq(&self, other: &SpinSleeper) -> bool
fn eq(&self, other: &SpinSleeper) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SpinSleeper) -> bool
fn ne(&self, other: &SpinSleeper) -> bool
This method tests for !=
.
impl Copy for SpinSleeper
impl Eq for SpinSleeper
impl StructuralEq for SpinSleeper
impl StructuralPartialEq for SpinSleeper
Auto Trait Implementations
impl RefUnwindSafe for SpinSleeper
impl Send for SpinSleeper
impl Sync for SpinSleeper
impl Unpin for SpinSleeper
impl UnwindSafe for SpinSleeper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more