Created
September 13, 2018 16:59
-
-
Save ryochack/2d7e56200c8454dcf3723986c8dd22e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate mio; | |
| use mio::unix::EventedFd; | |
| use mio::{Token, PollOpt, Ready, Poll, Events}; | |
| use std::io::ErrorKind; | |
| use std::time::Duration; | |
| fn main() { | |
| const IN: Token = Token(0); | |
| let fd0_e = EventedFd(&0); | |
| let poll = Poll::new().unwrap(); | |
| poll.register(&fd0_e, IN, Ready::readable(), | |
| PollOpt::edge()).unwrap(); | |
| let mut events = Events::with_capacity(1024); | |
| 'outer: loop { | |
| let ret = poll.poll(&mut events, Some(Duration::from_secs(5))); | |
| if let Err(x) = ret { | |
| eprintln!("Boo"); | |
| if x.kind() == ErrorKind::Interrupted { continue; } | |
| break; | |
| } | |
| if events.is_empty() { | |
| println!("_____TMO_____"); | |
| } | |
| for event in events.iter() { | |
| match event.token() { | |
| IN => println!("_____IN_____"), | |
| _ => unreachable!(), | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment