pub struct AtomicOptionRefArray<T> { /* private fields */ }
Expand description
An array of references in which elements may be updated and retrieved atomically.
This is a Rust interpretation of AtomicReferenceArray from Java.
Implementations§
Source§impl<T> AtomicOptionRefArray<T>
impl<T> AtomicOptionRefArray<T>
Sourcepub fn new(len: usize) -> Self
pub fn new(len: usize) -> Self
Constructs a new array with the specified length.
All values will be None
.
Sourcepub fn new_with<U: IntoOptionArc<T>>(len: usize, f: impl Fn(usize) -> U) -> Self
pub fn new_with<U: IntoOptionArc<T>>(len: usize, f: impl Fn(usize) -> U) -> Self
Constructs a new array with the specified length. Uses the given function to construct each value.
Sourcepub fn load(&self, index: usize) -> Option<Arc<T>>
pub fn load(&self, index: usize) -> Option<Arc<T>>
Loads and returns a reference to an value at the given position or None
if the value at the index is not set.
Panics if index
is out of bounds.
Sourcepub fn store(&self, index: usize, value: impl IntoOptionArc<T>)
pub fn store(&self, index: usize, value: impl IntoOptionArc<T>)
Stores the value at the given position.
Panics if index
is out of bounds.
Auto Trait Implementations§
impl<T> Freeze for AtomicOptionRefArray<T>
impl<T> RefUnwindSafe for AtomicOptionRefArray<T>
impl<T> Send for AtomicOptionRefArray<T>
impl<T> Sync for AtomicOptionRefArray<T>
impl<T> Unpin for AtomicOptionRefArray<T>
impl<T> UnwindSafe for AtomicOptionRefArray<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