diff options
author | Carl Lerche <me@carllerche.com> | 2018-02-01 10:31:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 10:31:07 -0800 |
commit | 2e94b658ed161ef7207a8decb20564556e9883f8 (patch) | |
tree | b5ae64e1760a4b648398290f7958cd202a470c8b /examples | |
parent | b9db119b456427d655b651f4f16d4266e6e16d98 (diff) |
Track futures tokio-reform branch (#88)
This patch also updates tests and examples to remove deprecated API
usage.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/chat.rs | 4 | ||||
-rw-r--r-- | examples/compress.rs | 4 | ||||
-rw-r--r-- | examples/connect.rs | 8 | ||||
-rw-r--r-- | examples/echo-threads.rs | 6 | ||||
-rw-r--r-- | examples/echo-udp.rs | 6 | ||||
-rw-r--r-- | examples/echo.rs | 4 | ||||
-rw-r--r-- | examples/hello.rs | 3 | ||||
-rw-r--r-- | examples/proxy.rs | 4 | ||||
-rw-r--r-- | examples/sink.rs | 4 | ||||
-rw-r--r-- | examples/tinydb.rs | 4 | ||||
-rw-r--r-- | examples/tinyhttp.rs | 5 | ||||
-rw-r--r-- | examples/udp-codec.rs | 4 |
12 files changed, 28 insertions, 28 deletions
diff --git a/examples/chat.rs b/examples/chat.rs index 76e689b9..667f0e9a 100644 --- a/examples/chat.rs +++ b/examples/chat.rs @@ -29,7 +29,7 @@ use std::io::{Error, ErrorKind, BufReader}; use std::sync::{Arc, Mutex}; use futures::Future; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures::stream::{self, Stream}; use futures_cpupool::CpuPool; use tokio::net::TcpListener; @@ -134,5 +134,5 @@ fn main() { }); // execute server - srv.wait().unwrap(); + future::blocking(srv).wait().unwrap(); } diff --git a/examples/compress.rs b/examples/compress.rs index 3098abf7..501548ef 100644 --- a/examples/compress.rs +++ b/examples/compress.rs @@ -29,7 +29,7 @@ use std::env; use std::net::SocketAddr; use futures::{Future, Stream, Poll}; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures_cpupool::CpuPool; use tokio::net::{TcpListener, TcpStream}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -62,7 +62,7 @@ fn main() { Ok(()) }); - server.wait().unwrap(); + future::blocking(server).wait().unwrap(); } /// The main workhorse of this example. This'll compress all data read from diff --git a/examples/connect.rs b/examples/connect.rs index 1bdc1af4..f0619fbd 100644 --- a/examples/connect.rs +++ b/examples/connect.rs @@ -26,7 +26,7 @@ use std::net::SocketAddr; use std::thread; use futures::sync::mpsc; -use futures::{Sink, Future, Stream}; +use futures::{future, Sink, Stream}; use futures_cpupool::CpuPool; fn main() { @@ -71,9 +71,9 @@ fn main() { // loop. In this case, though, we know it's ok as the event loop isn't // otherwise running anything useful. let mut out = io::stdout(); - stdout.for_each(|chunk| { + future::blocking(stdout.for_each(|chunk| { out.write_all(&chunk) - }).wait().unwrap(); + })).wait().unwrap(); } mod tcp { @@ -244,7 +244,7 @@ fn read_stdin(mut tx: mpsc::Sender<Vec<u8>>) { Ok(n) => n, }; buf.truncate(n); - tx = match tx.send(buf).wait() { + tx = match future::blocking(tx.send(buf)).wait() { Ok(tx) => tx, Err(_) => break, }; diff --git a/examples/echo-threads.rs b/examples/echo-threads.rs index 6ce8b156..e2525c80 100644 --- a/examples/echo-threads.rs +++ b/examples/echo-threads.rs @@ -24,7 +24,7 @@ use std::net::SocketAddr; use std::thread; use futures::prelude::*; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures::sync::mpsc; use futures_cpupool::CpuPool; use tokio_io::AsyncRead; @@ -61,7 +61,7 @@ fn main() { next = (next + 1) % channels.len(); Ok(()) }); - srv.wait().unwrap(); + future::blocking(srv).wait().unwrap(); } fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) { @@ -88,5 +88,5 @@ fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) { Ok(()) }); - done.wait().unwrap(); + future::blocking(done).wait().unwrap(); } diff --git a/examples/echo-udp.rs b/examples/echo-udp.rs index f7e2bf09..2ce43bc0 100644 --- a/examples/echo-udp.rs +++ b/examples/echo-udp.rs @@ -18,7 +18,7 @@ extern crate tokio_io; use std::{env, io}; use std::net::SocketAddr; -use futures::{Future, Poll}; +use futures::{future, Future, Poll}; use tokio::net::UdpSocket; struct Server { @@ -58,9 +58,9 @@ fn main() { // Next we'll create a future to spawn (the one we defined above) and then // we'll block our current thread waiting on the result of the future - Server { + future::blocking(Server { socket: socket, buf: vec![0; 1024], to_send: None, - }.wait().unwrap(); + }).wait().unwrap(); } diff --git a/examples/echo.rs b/examples/echo.rs index 558f3a68..54a28ff7 100644 --- a/examples/echo.rs +++ b/examples/echo.rs @@ -26,7 +26,7 @@ use std::env; use std::net::SocketAddr; use futures::Future; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures::stream::Stream; use futures_cpupool::CpuPool; use tokio_io::AsyncRead; @@ -114,5 +114,5 @@ fn main() { // And finally now that we've define what our server is, we run it! Here we // just need to execute the future we've created and wait for it to complete // using the standard methods in the `futures` crate. - done.wait().unwrap(); + future::blocking(done).wait().unwrap(); } diff --git a/examples/hello.rs b/examples/hello.rs index 5ceb431b..d9e46d17 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -19,6 +19,7 @@ extern crate tokio_io; use std::env; use std::net::SocketAddr; +use futures::future; use futures::prelude::*; use tokio::net::TcpListener; @@ -40,5 +41,5 @@ fn main() { Ok(()) }); - server.wait().unwrap(); + future::blocking(server).wait().unwrap(); } diff --git a/examples/proxy.rs b/examples/proxy.rs index 51735ba1..f73dd30d 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -28,7 +28,7 @@ use std::io::{self, Read, Write}; use futures::stream::Stream; use futures::{Future, Poll}; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures_cpupool::CpuPool; use tokio::net::{TcpListener, TcpStream}; use tokio_io::{AsyncRead, AsyncWrite}; @@ -92,7 +92,7 @@ fn main() { Ok(()) }); - done.wait().unwrap(); + future::blocking(done).wait().unwrap(); } // This is a custom type used to have a custom implementation of the diff --git a/examples/sink.rs b/examples/sink.rs index 21456ada..3fa5f5ed 100644 --- a/examples/sink.rs +++ b/examples/sink.rs @@ -26,7 +26,7 @@ use std::iter; use std::net::SocketAddr; use futures::Future; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures::stream::{self, Stream}; use futures_cpupool::CpuPool; use tokio_io::IoFuture; @@ -46,7 +46,7 @@ fn main() { pool.execute(write(socket).or_else(|_| Ok(()))).unwrap(); Ok(()) }); - server.wait().unwrap(); + future::blocking(server).wait().unwrap(); } fn write(socket: TcpStream) -> IoFuture<()> { diff --git a/examples/tinydb.rs b/examples/tinydb.rs index 0a68a314..de750404 100644 --- a/examples/tinydb.rs +++ b/examples/tinydb.rs @@ -51,7 +51,7 @@ use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use futures::prelude::*; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures_cpupool::CpuPool; use tokio::net::TcpListener; use tokio_io::AsyncRead; @@ -160,7 +160,7 @@ fn main() { Ok(()) }); - done.wait().unwrap(); + future::blocking(done).wait().unwrap(); } impl Request { diff --git a/examples/tinyhttp.rs b/examples/tinyhttp.rs index 00c16fec..b0106d63 100644 --- a/examples/tinyhttp.rs +++ b/examples/tinyhttp.rs @@ -31,8 +31,7 @@ use std::net::{self, SocketAddr}; use std::thread; use bytes::BytesMut; -use futures::future::Executor; -use futures::future; +use futures::future::{self, Executor}; use futures::sync::mpsc; use futures::{Stream, Future, Sink}; use futures_cpupool::CpuPool; @@ -91,7 +90,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) { })).unwrap(); Ok(()) }); - done.wait().unwrap(); + future::blocking(done).wait().unwrap(); } /// "Server logic" is implemented in this function. diff --git a/examples/udp-codec.rs b/examples/udp-codec.rs index c874ebd7..5c11e9f3 100644 --- a/examples/udp-codec.rs +++ b/examples/udp-codec.rs @@ -15,7 +15,7 @@ use std::io; use std::net::SocketAddr; use futures::{Future, Stream, Sink}; -use futures::future::Executor; +use futures::future::{self, Executor}; use futures_cpupool::CpuPool; use tokio::net::{UdpSocket, UdpCodec}; @@ -76,5 +76,5 @@ fn main() { // Spawn the sender of pongs and then wait for our pinger to finish. pool.execute(b.then(|_| Ok(()))).unwrap(); - drop(a.wait()); + drop(future::blocking(a).wait()); } |