mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-19 00:00:09 +02:00
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:
+6
-1
@@ -17,6 +17,7 @@
|
||||
//! the echo server, and you'll be able to see data flowing between them.
|
||||
|
||||
extern crate futures;
|
||||
extern crate futures_cpupool;
|
||||
extern crate tokio;
|
||||
extern crate tokio_io;
|
||||
|
||||
@@ -27,6 +28,8 @@ use std::io::{self, Read, Write};
|
||||
|
||||
use futures::stream::Stream;
|
||||
use futures::{Future, Poll};
|
||||
use futures::future::Executor;
|
||||
use futures_cpupool::CpuPool;
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
use tokio::reactor::Core;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
@@ -43,6 +46,8 @@ fn main() {
|
||||
let mut l = Core::new().unwrap();
|
||||
let handle = l.handle();
|
||||
|
||||
let pool = CpuPool::new(1);
|
||||
|
||||
// Create a TCP listener which will listen for incoming connections.
|
||||
let socket = TcpListener::bind(&listen_addr, &l.handle()).unwrap();
|
||||
println!("Listening on: {}", listen_addr);
|
||||
@@ -88,7 +93,7 @@ fn main() {
|
||||
// Don't panic. Maybe the client just disconnected too soon.
|
||||
println!("error: {}", e);
|
||||
});
|
||||
handle.spawn(msg);
|
||||
pool.execute(msg).unwrap();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user