mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
Remove Handle argument from I/O constructors (#61)
This commit removes the `Handle` argument from the following constructors * `TcpListener::bind` * `TcpStream::connect` * `UdpSocket::bind` The `Handle` argument remains on the various `*_std` constructors as they're more low-level, but this otherwise is intended to set forth a precedent of by default not taking `Handle` arguments and instead relying on the global `Handle::default` return value when necesary.
This commit is contained in:
committed by
Carl Lerche
parent
849771ecfa
commit
4ef772b2db
@@ -13,7 +13,6 @@ use futures::{Future, Stream, Sink};
|
||||
use futures::future::Executor;
|
||||
use futures_cpupool::CpuPool;
|
||||
use tokio::net::{TcpListener, TcpStream};
|
||||
use tokio::reactor::Handle;
|
||||
use tokio_io::codec::{Encoder, Decoder};
|
||||
use tokio_io::io::{write_all, read};
|
||||
use tokio_io::AsyncRead;
|
||||
@@ -56,9 +55,8 @@ fn echo() {
|
||||
drop(env_logger::init());
|
||||
|
||||
let pool = CpuPool::new(1);
|
||||
let handle = Handle::default();
|
||||
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &handle).unwrap();
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let pool_inner = pool.clone();
|
||||
let srv = listener.incoming().for_each(move |(socket, _)| {
|
||||
@@ -69,7 +67,7 @@ fn echo() {
|
||||
|
||||
pool.execute(srv.map_err(|e| panic!("srv error: {}", e))).unwrap();
|
||||
|
||||
let client = TcpStream::connect(&addr, &handle);
|
||||
let client = TcpStream::connect(&addr);
|
||||
let client = client.wait().unwrap();
|
||||
let (client, _) = write_all(client, b"a\n").wait().unwrap();
|
||||
let (client, buf, amt) = read(client, vec![0; 1024]).wait().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user