Init Event Module #4
22
src/main.rs
22
src/main.rs
@ -1,17 +1,26 @@
|
||||
use std::thread;
|
||||
use launchpad::core::events::{Event, Severity};
|
||||
use std::sync::mpsc::{channel};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
basic_event_test();
|
||||
}
|
||||
|
||||
fn basic_event_test() {
|
||||
let test_event_0 = Event::new(Severity::INFO, 0, 0);
|
||||
let (event_sender, event_receiver) = channel();
|
||||
let t0_sender = event_sender.clone();
|
||||
let t0 = thread::spawn(move || {
|
||||
t0_sender.send(test_event_0.unwrap()).expect("Sending event from t0 failed");
|
||||
t0_sender
|
||||
.send(test_event_0.unwrap())
|
||||
.expect("Sending event from t0 failed");
|
||||
});
|
||||
|
||||
let test_event_1 = Event::new(Severity::MEDIUM, 1, 8);
|
||||
let t1 = thread::spawn(move || {
|
||||
event_sender.send(test_event_1.unwrap()).expect("Sending event from t1 failed");
|
||||
event_sender
|
||||
.send(test_event_1.unwrap())
|
||||
.expect("Sending event from t1 failed");
|
||||
});
|
||||
|
||||
let mut event_cntr = 0;
|
||||
@ -21,11 +30,12 @@ fn main() {
|
||||
println!("Received event {:?}", event);
|
||||
event_cntr += 1;
|
||||
}
|
||||
Err(_) => { ()
|
||||
Err(_) => {
|
||||
()
|
||||
// println!("Received error {:?}", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
t0.join().unwrap();
|
||||
t1.join().unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user