pub struct RelaxedCounter(/* private fields */);
Expand description
Implementation of AtomicCounter
that uses
Relaxed
memory ordering.
See crate level documentation for more details.
Note that all operations wrap if the counter is incremented beyond usize::max_value().
Implementations§
Source§impl RelaxedCounter
impl RelaxedCounter
Sourcepub fn new(initial_count: usize) -> RelaxedCounter
pub fn new(initial_count: usize) -> RelaxedCounter
Creates a new counter with initial_value
Trait Implementations§
Source§impl AtomicCounter for RelaxedCounter
impl AtomicCounter for RelaxedCounter
Source§type PrimitiveType = usize
type PrimitiveType = usize
Underlying primitive type that is being shared atomically.
Source§fn inc(&self) -> usize
fn inc(&self) -> usize
Atomically increments the counter by one, returning the previous value.
Source§fn add(&self, amount: usize) -> usize
fn add(&self, amount: usize) -> usize
Atomically increments the counter by amount, returning the previous value.
Source§fn get(&self) -> usize
fn get(&self) -> usize
Atomically gets the current value of the counter, without modifying the counter.
Source§fn reset(&self) -> usize
fn reset(&self) -> usize
Atomically returns the current value of the counter, while resetting to count to zero.
Source§fn into_inner(self) -> usize
fn into_inner(self) -> usize
Consume the atomic counter and return the primitive type. Read more
Source§impl Debug for RelaxedCounter
impl Debug for RelaxedCounter
Source§impl Default for RelaxedCounter
impl Default for RelaxedCounter
Source§fn default() -> RelaxedCounter
fn default() -> RelaxedCounter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for RelaxedCounter
impl RefUnwindSafe for RelaxedCounter
impl Send for RelaxedCounter
impl Sync for RelaxedCounter
impl Unpin for RelaxedCounter
impl UnwindSafe for RelaxedCounter
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