• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::sys::windows::Event;
2 use crate::sys::windows::Selector;
3 use crate::Token;
4 
5 use miow::iocp::CompletionPort;
6 use std::io;
7 use std::sync::Arc;
8 
9 #[derive(Debug)]
10 pub struct Waker {
11     token: Token,
12     port: Arc<CompletionPort>,
13 }
14 
15 impl Waker {
new(selector: &Selector, token: Token) -> io::Result<Waker>16     pub fn new(selector: &Selector, token: Token) -> io::Result<Waker> {
17         Ok(Waker {
18             token,
19             port: selector.clone_port(),
20         })
21     }
22 
wake(&self) -> io::Result<()>23     pub fn wake(&self) -> io::Result<()> {
24         let mut ev = Event::new(self.token);
25         ev.set_readable();
26 
27         self.port.post(ev.to_completion_status())
28     }
29 }
30