pub struct Delta<U: TimeUnit = Nsec> { /* private fields */ }Expand description
Implementations§
Source§impl Delta<Jiffy>
impl Delta<Jiffy>
Sourcepub const fn from_jiffies(jiffies: isize) -> Self
pub const fn from_jiffies(jiffies: isize) -> Self
Create a new Delta from a number of jiffies.
Sourcepub const fn as_jiffies(self) -> isize
pub const fn as_jiffies(self) -> isize
Return the number of jiffies in the Delta.
Source§impl Delta
impl Delta
Sourcepub const fn from_nanos(nanos: i64) -> Self
pub const fn from_nanos(nanos: i64) -> Self
Create a new Delta from a number of nanoseconds.
Sourcepub const fn from_micros(micros: i64) -> Self
pub const fn from_micros(micros: i64) -> Self
Create a new Delta from a number of microseconds.
The micros can range from -9_223_372_036_854_775 to 9_223_372_036_854_775.
If micros is outside this range, i64::MIN is used for negative values,
and i64::MAX is used for positive values due to saturation.
Sourcepub const fn from_millis(millis: i64) -> Self
pub const fn from_millis(millis: i64) -> Self
Create a new Delta from a number of milliseconds.
The millis can range from -9_223_372_036_854 to 9_223_372_036_854.
If millis is outside this range, i64::MIN is used for negative values,
and i64::MAX is used for positive values due to saturation.
Sourcepub const fn from_secs(secs: i64) -> Self
pub const fn from_secs(secs: i64) -> Self
Create a new Delta from a number of seconds.
The secs can range from -9_223_372_036 to 9_223_372_036.
If secs is outside this range, i64::MIN is used for negative values,
and i64::MAX is used for positive values due to saturation.
Sourcepub fn is_negative(self) -> bool
pub fn is_negative(self) -> bool
Return true if the Delta spans a negative amount of time.
Sourcepub fn as_micros_ceil(self) -> i64
pub fn as_micros_ceil(self) -> i64
Return the smallest number of microseconds greater than or equal
to the value in the Delta.
Sourcepub fn as_millis_ceil(self) -> i64
pub fn as_millis_ceil(self) -> i64
Return the smallest number of milliseconds greater than or equal
to the value in the Delta.
Sourcepub fn to_jiffies_timeout(self) -> Delta<Jiffy>
pub fn to_jiffies_timeout(self) -> Delta<Jiffy>
Convert this span to a Delta<Jiffy> suitable for use as a timeout.
Unless the result saturates, the value is rounded up to the next whole
jiffy, so the resulting timeout is never shorter than self.
A negative span saturates at zero jiffies, i.e. an immediate timeout.
A span that does not fit saturates at the kernel’s MAX_JIFFY_OFFSET,
the upper bound for a jiffies span. That is a finite timeout, so a
saturated result can be shorter than the requested span. It is derived
from long, so only 32 bit can reach it, at about 12 days with HZ=1000.
§Examples
use kernel::time::Delta;
// A negative span is an immediate timeout.
assert_eq!(Delta::from_millis(-1).to_jiffies_timeout().as_jiffies(), 0);
// A span shorter than a jiffy still waits, i.e. the timeout is never
// shorter than the span.
assert!(Delta::from_nanos(1).to_jiffies_timeout().as_jiffies() >= 1);Trait Implementations§
Source§impl AddAssign for Delta
impl AddAssign for Delta
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreimpl<U: Copy + TimeUnit> Copy for Delta<U>
impl<U: Eq + TimeUnit> Eq for Delta<U>
Source§impl HrTimerExpires for Delta
impl HrTimerExpires for Delta
Source§impl MulAssign<i64> for Delta
impl MulAssign<i64> for Delta
Source§fn mul_assign(&mut self, rhs: i64)
fn mul_assign(&mut self, rhs: i64)
*= operation. Read moreSource§impl<U: Ord + TimeUnit> Ord for Delta<U>
impl<U: Ord + TimeUnit> Ord for Delta<U>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<U: PartialOrd + TimeUnit> PartialOrd for Delta<U>where
U::Repr: PartialOrd,
impl<U: PartialOrd + TimeUnit> PartialOrd for Delta<U>where
U::Repr: PartialOrd,
impl<U: PartialEq + TimeUnit> StructuralPartialEq for Delta<U>
Auto Trait Implementations§
impl<U> Freeze for Delta<U>
impl<U> RefUnwindSafe for Delta<U>
impl<U> Send for Delta<U>
impl<U> Sync for Delta<U>
impl<U> Unpin for Delta<U>
impl<U> UnsafeUnpin for Delta<U>
impl<U> UnwindSafe for Delta<U>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
impl<S, T> IntoSafeCast<T> for Swhere
T: FromSafeCast<S>,
Source§fn into_safe_cast(self) -> T
fn into_safe_cast(self) -> T
self into a T. This operation is guaranteed to be lossless.Source§impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
impl<S, T> IntoSafeCastArch<T> for Swhere
T: FromSafeCastArch<S>,
Source§fn into_safe_cast_arch(self) -> T
fn into_safe_cast_arch(self) -> T
self into a T. This operation is guaranteed to be lossless.