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§
Source§impl<T> AtomicPtr<T>
impl<T> AtomicPtr<T>
Sourcepub const fn new(p: *mut T) -> AtomicPtr<T>
pub const fn new(p: *mut T) -> AtomicPtr<T>
Creates a new AtomicPtr.
§Examples
use msp430_atomic::AtomicPtr;
let ptr = &mut 5;
let atomic_ptr = AtomicPtr::new(ptr);Sourcepub fn get_mut(&mut self) -> &mut *mut T
pub fn get_mut(&mut self) -> &mut *mut T
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);Sourcepub fn into_inner(self) -> *mut T
pub fn into_inner(self) -> *mut T
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);Trait Implementations§
impl<T> Send for AtomicPtr<T>
impl<T> Sync for AtomicPtr<T>
Auto Trait Implementations§
impl<T> !Freeze for AtomicPtr<T>
impl<T> !RefUnwindSafe for AtomicPtr<T>
impl<T> Unpin for AtomicPtr<T>
impl<T> UnwindSafe for AtomicPtr<T>where
T: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more