Struct atomic_array::AtomicRefArray [−][src]
pub struct AtomicRefArray<T> { /* fields omitted */ }
An array of non-optional references in which elements may be updated and retrieved atomically.
Methods
impl<T> AtomicRefArray<T>
[src]
impl<T> AtomicRefArray<T>
pub fn new(len: usize) -> Self where
T: Default,
[src]
pub fn new(len: usize) -> Self where
T: Default,
Constructs a new array with the specified length. All values will be initialized to their default.
pub fn new_with<U: Into<Arc<T>>>(
len: usize,
f: impl Fn(usize) -> U
) -> Self
[src]
pub fn new_with<U: Into<Arc<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.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in the array.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true
if the array has a length of 0.
pub fn load(&self, index: usize) -> Arc<T>
[src]
pub fn load(&self, index: usize) -> 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.
pub fn store(
&self,
index: usize,
value: impl Into<Arc<T>>
)
[src]
pub fn store(
&self,
index: usize,
value: impl Into<Arc<T>>
)
Stores the value at the given position.
Panics if index
is out bounds.
pub fn swap(
&self,
index: usize,
value: impl Into<Arc<T>>
) -> Arc<T>
[src]
pub fn swap(
&self,
index: usize,
value: impl Into<Arc<T>>
) -> Arc<T>
Swaps the value at the given position, returning the previous value.
Panics if index
is out of bounds.
Auto Trait Implementations
impl<T> Send for AtomicRefArray<T>
impl<T> Send for AtomicRefArray<T>
impl<T> Sync for AtomicRefArray<T>
impl<T> Sync for AtomicRefArray<T>