Struct shareable::SharedObject [] [src]

pub struct SharedObject<T> { /* fields omitted */ }

Shareable object data element.

Shares a read only object between multiple instances using an AtomicPtr and a small sping lock.

Examples

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

let value1 = SharedObject::new(String::from("abc"));
let value2 = value1.clone();

let (tx, rx) = mpsc::channel();

let thread = thread::spawn(move || {
    rx.recv();
    assert_eq!(value2.get().as_str(), "xyz");
});

value1.set(String::from("xyz"));

tx.send(());
thread.join().unwrap();

Methods

impl<T> SharedObject<T>
[src]

Construct a new instance of the object.

Set the value of the object.

Returns the value of the object.

Trait Implementations

impl<T: Clone> Clone for SharedObject<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for SharedObject<T>
[src]

Implementation of Debug.

impl<T: Display> Display for SharedObject<T>
[src]

Implementation of Display.