Struct shareable::SharedU32 [] [src]

pub struct SharedU32 { /* fields omitted */ }

Shareable u32 data element.

Examples

use std::sync::mpsc;
use std::thread;
use shareable::SharedU32;

// Multiple threads, atomic values are used.
let value1 = SharedU32::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 SharedU32
[src]

Construct a new instance of the object.

Set the value of the object.

Returns the value of the object.

Trait Implementations

impl Clone for SharedU32
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for SharedU32
[src]

Implementation of Debug.

impl Display for SharedU32
[src]

Implementation of Display.