Struct orx_concurrent_iter::AtomicCounter
source · pub struct AtomicCounter { /* private fields */ }
Expand description
An atomic counter, simply a wrapper around AtomicUsize
with utility methods useful for atomic iterators.
Implementations§
source§impl AtomicCounter
impl AtomicCounter
sourcepub fn fetch_and_add(&self, len: usize) -> usize
pub fn fetch_and_add(&self, len: usize) -> usize
Fetches and returns the current value of the counter, and adds len
to it.
sourcepub fn fetch_and_increment(&self) -> usize
pub fn fetch_and_increment(&self) -> usize
Fetches and returns the current value of the counter, and adds 1
to it.
sourcepub fn store(&self, new_value: usize)
pub fn store(&self, new_value: usize)
Updates the value of the current value of the counter as the given new_value
.
sourcepub fn get_current_max_value(&self, max_value: usize) -> usize
pub fn get_current_max_value(&self, max_value: usize) -> usize
Updates the current value to the max of the current and provided max_value
,
and returns the previous value.
This method is most useful for early exits and concurrently consuming the iterator.
Trait Implementations§
source§impl Clone for AtomicCounter
impl Clone for AtomicCounter
source§impl Debug for AtomicCounter
impl Debug for AtomicCounter
Auto Trait Implementations§
impl !Freeze for AtomicCounter
impl RefUnwindSafe for AtomicCounter
impl Send for AtomicCounter
impl Sync for AtomicCounter
impl Unpin for AtomicCounter
impl UnwindSafe for AtomicCounter
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)