Remove executor from reactor.

In accordance with tokio-rs/tokio-rfcs#3, the executor functionality of
Tokio is being removed and will be relocated into futures-rs as a
"current thread" executor.

This PR removes task execution from the code base. As a temporary
mesure, all examples and tests are switched to using CpuPool.

Depends on #19.
This commit is contained in:
Carl Lerche
2017-11-01 07:28:49 -07:00
parent 697851210c
commit c6f1ff13d2
14 changed files with 117 additions and 186 deletions
+6 -1
View File
@@ -17,6 +17,7 @@
extern crate env_logger;
extern crate futures;
extern crate futures_cpupool;
extern crate tokio;
extern crate tokio_io;
@@ -25,7 +26,9 @@ use std::iter;
use std::net::SocketAddr;
use futures::Future;
use futures::future::Executor;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio_io::IoFuture;
use tokio::net::{TcpListener, TcpStream};
use tokio::reactor::Core;
@@ -35,13 +38,15 @@ fn main() {
let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string());
let addr = addr.parse::<SocketAddr>().unwrap();
let pool = CpuPool::new(1);
let mut core = Core::new().unwrap();
let handle = core.handle();
let socket = TcpListener::bind(&addr, &handle).unwrap();
println!("Listening on: {}", addr);
let server = socket.incoming().for_each(|(socket, addr)| {
println!("got a socket: {}", addr);
handle.spawn(write(socket).or_else(|_| Ok(())));
pool.execute(write(socket).or_else(|_| Ok(()))).unwrap();
Ok(())
});
core.run(server).unwrap();