[−][src]Struct msp430_atomic::AtomicPtr
A raw pointer type which can be safely shared between threads.
This type has the same in-memory representation as a *mut T
.
Methods
impl<T> AtomicPtr<T>
[src]
pub const fn new(p: *mut T) -> AtomicPtr<T>
[src]
Creates a new AtomicPtr
.
Examples
use msp430_atomic::AtomicPtr; let ptr = &mut 5; let atomic_ptr = AtomicPtr::new(ptr);
pub fn get_mut(&mut self) -> &mut *mut T
[src]
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);
pub fn into_inner(self) -> *mut T
[src]
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);
pub fn load(&self) -> *mut T
[src]
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();
pub fn store(&self, ptr: *mut T)
[src]
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
impl<T> Debug for AtomicPtr<T>
[src]
impl<T> Default for AtomicPtr<T>
[src]
impl<T> Send for AtomicPtr<T>
[src]
impl<T> Sync for AtomicPtr<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,