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:
Alex Crichton
2017-12-12 18:32:50 -06:00
committed by Carl Lerche
parent 849771ecfa
commit 4ef772b2db
24 changed files with 48 additions and 98 deletions
+3 -7
View File
@@ -8,7 +8,6 @@ use std::thread;
use futures::Future;
use futures::stream::Stream;
use tokio::reactor::Handle;
use tokio::net::{TcpListener, TcpStream};
macro_rules! t {
@@ -21,14 +20,13 @@ macro_rules! t {
#[test]
fn connect() {
drop(env_logger::init());
let handle = Handle::default();
let srv = t!(net::TcpListener::bind("127.0.0.1:0"));
let addr = t!(srv.local_addr());
let t = thread::spawn(move || {
t!(srv.accept()).0
});
let stream = TcpStream::connect(&addr, &handle);
let stream = TcpStream::connect(&addr);
let mine = t!(stream.wait());
let theirs = t.join().unwrap();
@@ -39,8 +37,7 @@ fn connect() {
#[test]
fn accept() {
drop(env_logger::init());
let handle = Handle::default();
let srv = t!(TcpListener::bind(&t!("127.0.0.1:0".parse()), &handle));
let srv = t!(TcpListener::bind(&t!("127.0.0.1:0".parse())));
let addr = t!(srv.local_addr());
let (tx, rx) = channel();
@@ -64,8 +61,7 @@ fn accept() {
#[test]
fn accept2() {
drop(env_logger::init());
let handle = Handle::default();
let srv = t!(TcpListener::bind(&t!("127.0.0.1:0".parse()), &handle));
let srv = t!(TcpListener::bind(&t!("127.0.0.1:0".parse())));
let addr = t!(srv.local_addr());
let t = thread::spawn(move || {