Struct global_counter::primitive::fast::FlushingCounterU8 [−][src]
A flushing counter.
This counter is intended to be used in one specific way:
- First, all counting threads increment the counter.
- Every counting thread calls
flush
after it is done incrementing. - After every flush is guaranteed to have been executed,
get
will return the exact amount of timesinc
has been called (+ the start offset).
In theory, this counter is equivalent to an approximate counter with its resolution set to infinity.
Note that this counters inc
- flush
- get
- path does not induce a happens-before relationship,
as defined by the C++ standard.
In other words, it is not safe to rely solely on this counter for the synchronization of external data.
The most important example of this is spinning until a certain value is reached,
which does not guarantee any other operations to be visible to the reading thread.
Implementations
impl FlushingCounterU8
[src]
pub const fn new(start: u8) -> Self
[src]
Creates a new counter, with the given starting value. Can be used in static contexts.
pub fn inc(&self)
[src]
Increments the counter by one.
pub fn get(&self) -> u8
[src]
Gets the current value of the counter. This only returns the correct value after all local counters have been flushed.
pub fn flush(&self)
[src]
Flushes the local counter to the global.
Auto Trait Implementations
impl RefUnwindSafe for FlushingCounterU8
impl Send for FlushingCounterU8
impl Sync for FlushingCounterU8
impl Unpin for FlushingCounterU8
impl UnwindSafe for FlushingCounterU8
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,