Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Events/Rust/events.rust
Normal file
17
Task/Events/Rust/events.rust
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use std::{sync::mpsc, thread, time::Duration};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!("[1] Starting");
|
||||
let (tx, rx) = mpsc::channel();
|
||||
thread::spawn(move || {
|
||||
println!("[2] Waiting for event");
|
||||
rx.recv();
|
||||
println!("[2] Received event");
|
||||
});
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
println!("[1] Sending event");
|
||||
tx.send(())?;
|
||||
thread::sleep(Duration::from_secs(1));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue