Struct rw_cell::swmr::CellDistributor
source · pub struct CellDistributor<T> { /* private fields */ }Expand description
Distribute value between all readers
Implementations§
source§impl<T> CellDistributor<T>
impl<T> CellDistributor<T>
sourcepub fn new(val: T) -> CellDistributor<T>
pub fn new(val: T) -> CellDistributor<T>
Create new distributor
sourcepub fn write(&mut self, val: T)
pub fn write(&mut self, val: T)
Write val and distribute it between all readers
Example
fn main() {
let mut d = rw_cell::swmr::CellDistributor::new("Not good, but ok");
let mut r1 = d.get_reader();
let mut r2 = d.get_reader();
d.write("Not good");
assert_eq!(r1.read_with_is_new(), (&"Not good", true));
assert_eq!(r2.read_with_is_new(), (&"Not good", true));
}sourcepub fn read(&self) -> &T
pub fn read(&self) -> &T
Return value from cell
Example
fn main() {
let mut d = rw_cell::swmr::CellDistributor::new("Not good, but ok");
assert_eq!(d.read(), &"Not good, but ok");
}sourcepub fn get_reader(&mut self) -> CellReader<T>
pub fn get_reader(&mut self) -> CellReader<T>
Return new CellReader for read data from cell