mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-02 00:00:11 +02:00
Rename to tokio-core, add in futures-io
Renames the futures-mio crate to tokio-core, pulls in the futures-io crate under an `io` module, and gets everything compiling.
This commit is contained in:
+5
-6
@@ -5,8 +5,7 @@
|
||||
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
extern crate futures_io;
|
||||
extern crate futures_mio;
|
||||
extern crate tokio_core;
|
||||
|
||||
use std::env;
|
||||
use std::iter;
|
||||
@@ -14,13 +13,13 @@ use std::net::SocketAddr;
|
||||
|
||||
use futures::Future;
|
||||
use futures::stream::{self, Stream};
|
||||
use futures_io::IoFuture;
|
||||
use tokio_core::io::IoFuture;
|
||||
|
||||
fn main() {
|
||||
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
|
||||
let addr = addr.parse::<SocketAddr>().unwrap();
|
||||
|
||||
let mut l = futures_mio::Loop::new().unwrap();
|
||||
let mut l = tokio_core::Loop::new().unwrap();
|
||||
let server = l.handle().tcp_listen(&addr).and_then(|socket| {
|
||||
socket.incoming().and_then(|(socket, addr)| {
|
||||
println!("got a socket: {}", addr);
|
||||
@@ -34,10 +33,10 @@ fn main() {
|
||||
l.run(server).unwrap();
|
||||
}
|
||||
|
||||
fn write(socket: futures_mio::TcpStream) -> IoFuture<()> {
|
||||
fn write(socket: tokio_core::TcpStream) -> IoFuture<()> {
|
||||
static BUF: &'static [u8] = &[0; 64 * 1024];
|
||||
let iter = iter::repeat(()).map(|()| Ok(()));
|
||||
stream::iter(iter).fold(socket, |socket, ()| {
|
||||
futures_io::write_all(socket, BUF).map(|(socket, _)| socket)
|
||||
tokio_core::io::write_all(socket, BUF).map(|(socket, _)| socket)
|
||||
}).map(|_| ()).boxed()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user