pub struct ConsistentCounter(/* private fields */);
Expand description
Implementation of AtomicCounter
that uses
Sequentially Consistent
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 ConsistentCounter
impl ConsistentCounter
Sourcepub fn new(initial_count: usize) -> ConsistentCounter
pub fn new(initial_count: usize) -> ConsistentCounter
Creates a new counter with initial_value
Trait Implementations§
Source§impl AtomicCounter for ConsistentCounter
impl AtomicCounter for ConsistentCounter
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 ConsistentCounter
impl Debug for ConsistentCounter
Source§impl Default for ConsistentCounter
impl Default for ConsistentCounter
Source§fn default() -> ConsistentCounter
fn default() -> ConsistentCounter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ConsistentCounter
impl RefUnwindSafe for ConsistentCounter
impl Send for ConsistentCounter
impl Sync for ConsistentCounter
impl Unpin for ConsistentCounter
impl UnwindSafe for ConsistentCounter
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