Relax the 'static bound on Loop::run

We know that the future will never persist beyond this stack frame, so we can
just leave its ownership on the stack frame itself and receive notifications off
the event loop that we need to poll it.
This commit is contained in:
Alex Crichton
2016-08-17 23:34:44 -07:00
parent 9672f90091
commit 32eb457dad
2 changed files with 55 additions and 42 deletions
+4
View File
@@ -1,3 +1,4 @@
extern crate env_logger;
extern crate futures;
extern crate futures_mio;
@@ -17,6 +18,7 @@ macro_rules! t {
#[test]
fn connect() {
drop(env_logger::init());
let mut l = t!(futures_mio::Loop::new());
let srv = t!(TcpListener::bind("127.0.0.1:0"));
let addr = t!(srv.local_addr());
@@ -34,6 +36,7 @@ fn connect() {
#[test]
fn accept() {
drop(env_logger::init());
let mut l = t!(futures_mio::Loop::new());
let srv = l.handle().tcp_listen(&"127.0.0.1:0".parse().unwrap());
let srv = t!(l.run(srv));
@@ -59,6 +62,7 @@ fn accept() {
#[test]
fn accept2() {
drop(env_logger::init());
let mut l = t!(futures_mio::Loop::new());
let srv = l.handle().tcp_listen(&"127.0.0.1:0".parse().unwrap());
let srv = t!(l.run(srv));