mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
Swap Handle/Pinned
* Handle -> Remote * Pinned -> Handle All APIs now take a `&Handle` by default and in general can return an immediate `io::Result` instead of an `IoFuture`. This reflects how most usage will likely be done through handles rather than remotes, and also all previous functionality can be recovered with a `oneshot` plus `Remote::spawn`. Closes #15
This commit is contained in:
+8
-9
@@ -23,16 +23,15 @@ fn main() {
|
||||
let addr = addr.parse::<SocketAddr>().unwrap();
|
||||
|
||||
let mut l = Core::new().unwrap();
|
||||
let server = TcpListener::bind(&addr, &l.handle()).and_then(|socket| {
|
||||
socket.incoming().and_then(|(socket, addr)| {
|
||||
println!("got a socket: {}", addr);
|
||||
write(socket).or_else(|_| Ok(()))
|
||||
}).for_each(|()| {
|
||||
println!("lost the socket");
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
let socket = TcpListener::bind(&addr, &l.handle()).unwrap();
|
||||
println!("Listenering on: {}", addr);
|
||||
let server = socket.incoming().and_then(|(socket, addr)| {
|
||||
println!("got a socket: {}", addr);
|
||||
write(socket).or_else(|_| Ok(()))
|
||||
}).for_each(|()| {
|
||||
println!("lost the socket");
|
||||
Ok(())
|
||||
});
|
||||
l.run(server).unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user