Remove the Remote type

The `Handle` type is now `Send` and `Sync` so the `Remote` type no longer needs
to exist.
This commit is contained in:
Alex Crichton
2017-12-05 08:15:26 -08:00
parent c801584d24
commit 7c768fc046
4 changed files with 20 additions and 113 deletions
+3 -20
View File
@@ -82,26 +82,9 @@ impl TcpListener {
return Err(e)
},
Ok((sock, addr)) => {
// Fast path if we haven't left the event loop
if let Some(handle) = self.io.remote().handle() {
let io = try!(PollEvented::new(sock, &handle));
return Ok((TcpStream { io: io }, addr))
}
// If we're off the event loop then send the socket back
// over there to get registered and then we'll get it back
// eventually.
let (tx, rx) = oneshot::channel();
let remote = self.io.remote().clone();
remote.run(move |handle| {
let res = PollEvented::new(sock, handle)
.map(move |io| {
(TcpStream { io: io }, addr)
});
drop(tx.send(res));
});
self.pending_accept = Some(rx);
// continue to polling the `rx` at the beginning of the loop
let handle = self.io.handle();
let io = try!(PollEvented::new(sock, &handle));
return Ok((TcpStream { io: io }, addr))
}
}
}