hylarana_common::atomic

Trait EasyAtomic

Source
pub trait EasyAtomic {
    type Item;

    // Required methods
    fn update(&self, value: Self::Item) -> Self::Item;
    fn get(&self) -> Self::Item;
}

Required Associated Types§

Required Methods§

Source

fn update(&self, value: Self::Item) -> Self::Item

Update atomic value.

use std::sync::atomic::{AtomicU8, Ordering};
use sync::atomic::EasyAtomic;

impl EsayAtomic for AtomicU8 {
    type Item = u8;

    fn get(&self) -> Self::Item {
        self.load(Ordering::Relaxed)
    }

    fn update(&self, value: Self::Item) -> Self::Item {
        self.swap(value, Ordering::Relaxed)
    }
}
Source

fn get(&self) -> Self::Item

Get atomic value.

use std::sync::atomic::{AtomicU8, Ordering};
use sync::atomic::EasyAtomic;

impl EsayAtomic for AtomicU8 {
    type Item = u8;

    fn get(&self) -> Self::Item {
        self.load(Ordering::Relaxed)
    }

    fn update(&self, value: Self::Item) -> Self::Item {
        self.swap(value, Ordering::Relaxed)
    }
}

Implementations on Foreign Types§

Source§

impl EasyAtomic for AtomicBool

Source§

type Item = bool

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicI8

Source§

type Item = i8

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicI16

Source§

type Item = i16

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicI32

Source§

type Item = i32

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicI64

Source§

type Item = i64

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicIsize

Source§

type Item = isize

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicU8

Source§

type Item = u8

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicU16

Source§

type Item = u16

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicU32

Source§

type Item = u32

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicU64

Source§

type Item = u64

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Source§

impl EasyAtomic for AtomicUsize

Source§

type Item = usize

Source§

fn get(&self) -> Self::Item

Source§

fn update(&self, value: Self::Item) -> Self::Item

Implementors§