RefCount

Trait RefCount 

Source
pub trait RefCount {
    type Value;

    // Required methods
    fn one() -> Self;
    fn is_one(val: &Self::Value) -> bool;
    fn load_acquire(&self) -> Self::Value;
    fn fence_acquire(&self);
    fn fetch_inc_relaxed(&self) -> Self::Value;
    fn fetch_dec_release(&self) -> Self::Value;
}
Expand description

Trait for refcount

Some method names explain required memory ordering in multi-threaded context.

Required Associated Types§

Source

type Value

Type of count

Required Methods§

Source

fn one() -> Self

Creates a new RefCount object.

The object is initialized as “one”.

Source

fn is_one(val: &Self::Value) -> bool

Checks whether a value equals to one.

Source

fn load_acquire(&self) -> Self::Value

Gets a current value.

§Memory ordering

Acquire or stronger ordering is required if implementors are atomic types.

Source

fn fence_acquire(&self)

Memory fence.

This method is needed only for multi-threaded refcount. In single-threaded implementors, this can be NO-OP.

§Memory ordering

Acquire or stronger ordering is required if implementors are atomic types.

Source

fn fetch_inc_relaxed(&self) -> Self::Value

Increments its value and returns previous value.

§Memory ordering

Relaxed ordering is allowed if implementors are atomic types.

Source

fn fetch_dec_release(&self) -> Self::Value

Decrements its value and returns previous value.

§Memory ordering

Release or stronger ordering is required if implementors are atomic types.

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.

Implementations on Foreign Types§

Source§

impl RefCount for Cell<u8>

Source§

type Value = u8

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for Cell<u16>

Source§

type Value = u16

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for Cell<u32>

Source§

type Value = u32

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for Cell<u64>

Source§

type Value = u64

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for Cell<usize>

Source§

type Value = usize

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for AtomicU8

Source§

type Value = u8

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for AtomicU16

Source§

type Value = u16

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for AtomicU32

Source§

type Value = u32

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for AtomicU64

Source§

type Value = u64

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Source§

impl RefCount for AtomicUsize

Source§

type Value = usize

Source§

fn one() -> Self

Source§

fn is_one(val: &Self::Value) -> bool

Source§

fn load_acquire(&self) -> Self::Value

Source§

fn fence_acquire(&self)

Source§

fn fetch_inc_relaxed(&self) -> Self::Value

Source§

fn fetch_dec_release(&self) -> Self::Value

Implementors§