pub unsafe trait Counter<T>: Sized {
// Required methods
unsafe fn increment(&self);
unsafe fn decrement(&self) -> bool;
fn fence_acquire();
fn one() -> Self;
}Expand description
Counter trait for uniformed reference counting.
§Safety
The implementation must hold arithmetic invariants and respect synchronization.
Required Methods§
Sourceunsafe fn decrement(&self) -> bool
unsafe fn decrement(&self) -> bool
Decrement the counter by 1.
§Returns
true if the counter reaches zero.
§Safety
The caller must ensure that the counter will not underflow.
Counter::fence_acquire must be called after this if it returns true.
Sourcefn fence_acquire()
fn fence_acquire()
Issue an acquire fence.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.