Struct shareable::SharedBool
[−]
[src]
pub struct SharedBool { /* fields omitted */ }
Shareable boolean data element.
Examples
use std::sync::mpsc; use std::thread; use shareable::SharedBool; // Multiple threads, atomic values are used. let value1 = SharedBool::new(false); let value2 = value1.clone(); let (tx, rx) = mpsc::channel(); let thread = thread::spawn(move || { rx.recv(); assert_eq!(value2.get(), true); }); value1.set(true); tx.send(()); thread.join().unwrap();
Methods
impl SharedBool
[src]
fn new(value: bool) -> SharedBool
Construct a new instance of the object.
fn set(&self, value: bool)
Set the value of the object.
fn get(&self) -> bool
Returns the value of the object.
Trait Implementations
impl Clone for SharedBool
[src]
fn clone(&self) -> SharedBool
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