mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
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:
+3
-20
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user