Update examples to track latest Tokio changes (#180)

The exampes included in the repository have lagged behind the changes
made. Specifically, they do not use the new runtime construct.

This patch updates examples to use the latest features of Tokio.
This commit is contained in:
Carl Lerche
2018-03-06 09:59:04 -08:00
committed by GitHub
parent 56c5797872
commit f1cb12e14f
15 changed files with 412 additions and 741 deletions
+4 -7
View File
@@ -15,13 +15,10 @@
#![deny(warnings)]
extern crate tokio;
extern crate tokio_io;
extern crate futures;
use tokio::executor::current_thread;
use tokio::io;
use tokio::net::TcpListener;
use tokio_io::io;
use futures::{Future, Stream};
use tokio::prelude::*;
pub fn main() {
let addr = "127.0.0.1:6142".parse().unwrap();
@@ -43,7 +40,7 @@ pub fn main() {
});
// Spawn a new task that processes the socket:
current_thread::spawn(connection);
tokio::spawn(connection);
Ok(())
})
@@ -76,5 +73,5 @@ pub fn main() {
//
// In our example, we have not defined a shutdown strategy, so this will
// block until `ctrl-c` is pressed at the terminal.
current_thread::block_on_all(server).unwrap();
tokio::run(server);
}