#[cfg(not(feature = "async"))]
fn main() {
use std::thread::spawn;
use synchronized::sync;
let mut join_all = Vec::new();
for thread_id in 0..5 {
let join = spawn(move || {
println!("#[id: {}] {}", thread_id, sync_fn());
});
join_all.push(join);
}
for tjoin in join_all {
let _e = tjoin.join();
}
fn sync_fn() -> usize {
let result = sync! {
static mut POINT0: usize = 0;
static mut POINT1: usize = 0;
unsafe {
POINT1 = POINT0;
POINT0 += 1;
POINT1
}
};
result
}
}
#[cfg(feature = "async")]
fn main() {
println!("This example only builds and runs with --feature=\"sync\"");
}