extern crate users;
use users::{Users, UsersCache, uid_t};
use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::thread;
const LO: uid_t = 500;
const HI: uid_t = 510;
fn main() {
let cache = Arc::new(Mutex::new(UsersCache::new()));
for uid in LO .. HI {
let cache = cache.clone();
thread::spawn(move || {
let cache = cache.lock().unwrap(); let _ = cache.get_user_by_uid(uid); });
}
thread::sleep(Duration::from_millis(100));
for uid in LO .. HI {
let cache = cache.lock().unwrap(); if let Some(u) = cache.get_user_by_uid(uid) { println!("User #{} is {}", u.uid(), u.name())
}
else {
println!("User #{} does not exist", uid);
}
}
}