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