Struct shareable::SharedF32
[−]
[src]
pub struct SharedF32 { /* fields omitted */ }
Stores a f32 element inside an atomic element so it can be accessed by multiple threads.
Examples
use std::sync::mpsc; use std::thread; use shareable::SharedF32; let value1 = SharedF32::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();
Methods
impl SharedF32
[src]
fn new(value: f32) -> SharedF32
Construct a new instance of the object.
fn set(&self, val: f32)
Set the value of the object.
fn get(&self) -> f32
Returns the value of the object.
Trait Implementations
impl Clone for SharedF32
[src]
fn clone(&self) -> SharedF32
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more