extern crate pyroscope;
use std::sync::mpsc;
use pyroscope::timer::Timer;
fn main() {
let mut timer = Timer::initialize(std::time::Duration::from_secs(10)).unwrap();
let (tx, rx) = mpsc::channel();
let (tx2, rx2) = mpsc::channel();
timer.attach_listener(tx).unwrap();
timer.attach_listener(tx2).unwrap();
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs();
println!("Current Time: {}", now);
std::thread::spawn(move || {
#[allow(irrefutable_let_patterns)]
while let result = rx.recv() {
match result {
Ok(time) => println!("Thread 1 Notification: {}", time),
Err(_err) => {
println!("Error Thread 1");
break;
}
}
}
});
std::thread::spawn(move || {
#[allow(irrefutable_let_patterns)]
while let result = rx2.recv() {
match result {
Ok(time) => println!("Thread 2 Notification: {}", time),
Err(_err) => {
println!("Error Thread 2");
break;
}
}
}
})
.join()
.unwrap();
}