pub struct AtomicUnixInstant { /* private fields */ }
Expand description

An atomic precise measurement of the system clock.

Internally, it reprsents the instant as a whole number of nanoseconds from the UNIX epoch using an AtomicU64. This provides interior mutability with atomic operations.

See the crate::precise::UnixInstant type for more details.

Implementations§

source§

impl AtomicUnixInstant

source

pub fn new(value: UnixInstant) -> Self

Create a new AtomicUnixInstant representing the provided UnixInstant.

source

pub fn now() -> Self

Create a new AtomicUnixInstant representing the current instant.

source

pub fn load(&self, ordering: Ordering) -> UnixInstant

See: core::sync::atomic::AtomicU64::load for a description of the memory orderings.

§Panics

Panics if ordering is Release or AcqRel.

source

pub fn store(&self, value: UnixInstant, ordering: Ordering)

Stores a new value for the instant.

See: core::sync::atomic::AtomicU64::store for a description of the memory orderings.

§Panics

Panics if ordering is Acquire or AcqRel.

source

pub fn swap(&self, value: UnixInstant, ordering: Ordering) -> UnixInstant

Replaces the value of the instant and returns the previous value.

See: core::sync::atomic::AtomicU64::swap for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn compare_exchange( &self, current: UnixInstant, new: UnixInstant, success: Ordering, failure: Ordering ) -> Result<UnixInstant, UnixInstant>

Stores a new value for the instant if the current instant is the same as the current instant.

See: core::sync::atomic::AtomicU64::compare_exchange for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn compare_exchange_weak( &self, current: UnixInstant, new: UnixInstant, success: Ordering, failure: Ordering ) -> Result<UnixInstant, UnixInstant>

Stores a new value for the instant if the current instant is the same as the current instant.

See: core::sync::atomic::AtomicU64::compare_exchange for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn fetch_add(&self, value: Duration, ordering: Ordering) -> UnixInstant

Stores a new value for the instant if the current instant is the same as the current instant.

See: core::sync::atomic::AtomicU64::compare_exchange_weak for a description of the memory orderings.

Unlike AtomicDuration::compare_exchange, this function is allowed to spuriously fail. This allows for more efficient code on some platforms.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn fetch_max(&self, value: UnixInstant, ordering: Ordering) -> UnixInstant

Maximum with the current instant.

Finds the maximum of the current instant and the argument value, and sets the new instant to the result.

Returns the previous instant.

See: core::sync::atomic::AtomicU64::fetch_max for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn fetch_min(&self, value: UnixInstant, ordering: Ordering) -> UnixInstant

Minimum with the current instant.

Finds the minimum of the current instant and the argument val, and sets the new instant to the result.

Returns the previous instant.

See: core::sync::atomic::AtomicU64::fetch_min for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

source

pub fn fetch_sub(&self, value: Duration, ordering: Ordering) -> UnixInstant

Subtracts from the current instant, returning the previous instant.

This operation wraps around on overflow.

See: core::sync::atomic::AtomicU64::fetch_sub for a description of the memory orderings.

Note: This method is only available on platforms that support atomic operations on u64.

Trait Implementations§

source§

impl Debug for AtomicUnixInstant

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AtomicUnixInstant

source§

fn default() -> AtomicUnixInstant

Returns the “default value” for a type. Read more
source§

impl From<UnixInstant> for AtomicUnixInstant

source§

fn from(other: UnixInstant) -> Self

Converts to this type from the input type.
source§

impl From<UnixInstant> for AtomicUnixInstant

source§

fn from(other: UnixInstant) -> Self

Converts to this type from the input type.
source§

impl TryFrom<SystemTime> for AtomicUnixInstant

§

type Error = TryFromError

The type returned in the event of a conversion error.
source§

fn try_from(other: SystemTime) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.