mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +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
+7
-2
@@ -2,6 +2,7 @@ extern crate tokio;
|
||||
extern crate futures;
|
||||
|
||||
use std::thread;
|
||||
use std::net;
|
||||
|
||||
use futures::future;
|
||||
use futures::prelude::*;
|
||||
@@ -13,7 +14,9 @@ use tokio::reactor::Reactor;
|
||||
fn tcp_doesnt_block() {
|
||||
let core = Reactor::new().unwrap();
|
||||
let handle = core.handle();
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &handle).unwrap();
|
||||
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let listener = TcpListener::from_std(listener, &addr, &handle).unwrap();
|
||||
drop(core);
|
||||
assert!(listener.incoming().wait().next().unwrap().is_err());
|
||||
}
|
||||
@@ -22,7 +25,9 @@ fn tcp_doesnt_block() {
|
||||
fn drop_wakes() {
|
||||
let core = Reactor::new().unwrap();
|
||||
let handle = core.handle();
|
||||
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap(), &handle).unwrap();
|
||||
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let listener = TcpListener::from_std(listener, &addr, &handle).unwrap();
|
||||
let (tx, rx) = oneshot::channel::<()>();
|
||||
let t = thread::spawn(move || {
|
||||
let incoming = listener.incoming();
|
||||
|
||||
Reference in New Issue
Block a user