mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
Add a fast path to TcpListener::accept
This commit is contained in:
parent
b22b797278
commit
c9d0fe59dd
@ -78,6 +78,15 @@ 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.spawn(move |handle| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user