pub struct SharedF64 { /* private fields */ }
Expand description
Shareable f64 data element.
If the architecture is 64 bit then the value is saved in an atomic otherwise a mutex is used.
§Examples
use std::sync::mpsc;
use std::thread;
use shareable::SharedF64;
let value1 = SharedF64::new(63.23);
let value2 = value1.clone();
let (tx, rx) = mpsc::channel();
let thread = thread::spawn(move || {
rx.recv();
assert_eq!(value2.get(), 31.83);
});
value1.set(31.83);
tx.send(());
thread.join().unwrap();
Implementations§
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more