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§
Sourcefn update(&self, value: Self::Item) -> Self::Item
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)
}
}
Sourcefn get(&self) -> Self::Item
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)
}
}