1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/* Copyright 2016 Joshua Gentry * * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license * <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your * option. This file may not be copied, modified, or distributed * except according to those terms. */ //! This crate allows the sharing of various data objects via atomic memory operations to avoid //! the overhead of Mutex whenever possible. The SharedF32, SharedI8, SharedI16, SharedI32, //! SharedIsize, SharedU8, SharedU16, SharedU32, and SharedUsize objects basically just pass //! the data to the atomic elements. //! //! The SharedF64, SharedI64 and SharedU64 objects are useful when supporting both 32 and 64 bit //! environments. Under 64 bit environments they will use the faster atomic data objects to share //! the values, when compiled under 32 bit they will use the slower mutexes since the atomics only //! handle 32 bit values. //! //! The SharedObject will share a read only object. Internally it uses a very small spin lock to //! to insure accurate reference counting but should provide faster access than using a Mutex. //! //! # 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(); //! ``` mod shared_bool; mod shared_f32; mod shared_f64; mod shared_i8; mod shared_i16; mod shared_i32; mod shared_i64; mod shared_isize; mod shared_object; mod shared_u8; mod shared_u16; mod shared_u32; mod shared_u64; mod shared_usize; pub use shared_bool::SharedBool; pub use shared_f32::SharedF32; pub use shared_f64::SharedF64; pub use shared_i8::SharedI8; pub use shared_i16::SharedI16; pub use shared_i32::SharedI32; pub use shared_i64::SharedI64; pub use shared_isize::SharedIsize; pub use shared_object::SharedObject; pub use shared_u8::SharedU8; pub use shared_u16::SharedU16; pub use shared_u32::SharedU32; pub use shared_u64::SharedU64; pub use shared_usize::SharedUsize;