pub struct Counter(pub AtomicU64);Expand description
A thin wrapper around AtomicU64 that implements CloseValue.
This is provided for convenience to avoid the need to specify an ordering. However,
all other atomics also implement CloseValue and can be used directly.
Tuple Fields§
§0: AtomicU64Implementations§
Source§impl Counter
impl Counter
Sourcepub const fn new(starting_count: u64) -> Self
pub const fn new(starting_count: u64) -> Self
Create a new Counter, initialized a specific value
Sourcepub fn increment_scoped(&self) -> (CounterGuard<'_>, u64)
pub fn increment_scoped(&self) -> (CounterGuard<'_>, u64)
Increments the count by 1, returning a guard that decrements the count on drop, and the new value. Useful for tracking in-flight operations.
Sourcepub fn increment_owned(self: &Arc<Self>) -> (OwnedCounterGuard, u64)
pub fn increment_owned(self: &Arc<Self>) -> (OwnedCounterGuard, u64)
Increments the count by 1, returning an owned guard that decrements the count on drop, and the new value.
Unlike increment_scoped, the returned
OwnedCounterGuard can be moved across async boundaries or stored
in structs without lifetime constraints.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnsafeUnpin for Counter
impl UnwindSafe for Counter
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<C, T> CloseValueRef for Twhere
&'a T: for<'a> CloseValue<Closed = C>,
impl<C, T> CloseValueRef for Twhere
&'a T: for<'a> CloseValue<Closed = C>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
Write
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
Write
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
Write
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
Write
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
Write
value to writer