Struct shareable::SharedU64
[−]
[src]
pub struct SharedU64 { /* fields omitted */ }
Shareable u64 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::SharedU64; let value1 = SharedU64::new(63); let value2 = value1.clone(); let (tx, rx) = mpsc::channel(); let thread = thread::spawn(move || { rx.recv(); assert_eq!(value2.get(), 31); }); value1.set(31); tx.send(()); thread.join().unwrap();
Methods
impl SharedU64
[src]
fn new(value: u64) -> SharedU64
Construct a new instance of the object.
fn set(&self, value: u64)
Set the value of the object.
fn get(&self) -> u64
Returns the value of the object.
Trait Implementations
impl Clone for SharedU64
[src]
fn clone(&self) -> SharedU64
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