#[repr(C, align(8))]
pub struct AtomicPtr<T> { /* private fields */ }
Expand description

A raw pointer type which can be safely shared between threads.

This type has the same in-memory representation as a *mut T.

Implementations§

Creates a new AtomicPtr.

Examples
use msp430_atomic::AtomicPtr;

let ptr = &mut 5;
let atomic_ptr  = AtomicPtr::new(ptr);

Returns a mutable reference to the underlying pointer.

This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.

Examples
use msp430_atomic::AtomicPtr;

let mut atomic_ptr = AtomicPtr::new(&mut 10);
*atomic_ptr.get_mut() = &mut 5;
assert_eq!(unsafe { *atomic_ptr.load() }, 5);

Consumes the atomic and returns the contained value.

This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Examples
use msp430_atomic::AtomicPtr;

let atomic_ptr = AtomicPtr::new(&mut 5);
assert_eq!(unsafe { *atomic_ptr.into_inner() }, 5);

Loads a value from the pointer.

Examples
use msp430_atomic::AtomicPtr;

let ptr = &mut 5;
let some_ptr  = AtomicPtr::new(ptr);

let value = some_ptr.load();

Stores a value into the pointer.

Examples
use msp430_atomic::AtomicPtr;

let ptr = &mut 5;
let some_ptr  = AtomicPtr::new(ptr);

let other_ptr = &mut 10;

some_ptr.store(other_ptr);

Trait Implementations§

Formats the value using the given formatter. Read more

Creates a null AtomicPtr<T>.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.