summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2018-02-06 07:26:21 -0800
committerGitHub <noreply@github.com>2018-02-06 07:26:21 -0800
commitf0ea9d6f4c0a734ac4c235630f3d8cc51fb48f51 (patch)
tree011aae238269ce6ba1cf29013126e4e45fea4cd4 /examples
parent567887cc75170437f75f19f5966f2b32bf49ab72 (diff)
Switch back to futures from crates.io (#113)
Doing so requires copying the `current_thread` executor from GitHub into the repo.
Diffstat (limited to 'examples')
-rw-r--r--examples/chat-combinator.rs4
-rw-r--r--examples/chat.rs2
-rw-r--r--examples/compress.rs4
-rw-r--r--examples/connect.rs8
-rw-r--r--examples/echo-threads.rs6
-rw-r--r--examples/echo-udp.rs6
-rw-r--r--examples/echo.rs4
-rw-r--r--examples/hello.rs3
-rw-r--r--examples/hello_world.rs3
-rw-r--r--examples/proxy.rs5
-rw-r--r--examples/sink.rs4
-rw-r--r--examples/tinydb.rs4
-rw-r--r--examples/tinyhttp.rs2
-rw-r--r--examples/udp-codec.rs4
14 files changed, 30 insertions, 29 deletions
diff --git a/examples/chat-combinator.rs b/examples/chat-combinator.rs
index 667f0e9a..76e689b9 100644
--- a/examples/chat-combinator.rs
+++ b/examples/chat-combinator.rs
@@ -29,7 +29,7 @@ use std::io::{Error, ErrorKind, BufReader};
use std::sync::{Arc, Mutex};
use futures::Future;
-use futures::future::{self, Executor};
+use futures::future::Executor;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
@@ -134,5 +134,5 @@ fn main() {
});
// execute server
- future::blocking(srv).wait().unwrap();
+ srv.wait().unwrap();
}
diff --git a/examples/chat.rs b/examples/chat.rs
index da8889fd..1b155427 100644
--- a/examples/chat.rs
+++ b/examples/chat.rs
@@ -33,10 +33,10 @@ extern crate tokio;
extern crate tokio_io;
extern crate bytes;
+use tokio::executor::current_thread;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead};
use futures::prelude::*;
-use futures::current_thread;
use futures::sync::mpsc;
use futures::future::{self, Either};
use bytes::{BytesMut, Bytes, BufMut};
diff --git a/examples/compress.rs b/examples/compress.rs
index 501548ef..3098abf7 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::{self, Executor};
+use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead, AsyncWrite};
@@ -62,7 +62,7 @@ fn main() {
Ok(())
});
- future::blocking(server).wait().unwrap();
+ 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 f0619fbd..a4160449 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::{future, Sink, 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();
- future::blocking(stdout.for_each(|chunk| {
+ 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 future::blocking(tx.send(buf)).wait() {
+ tx = match tx.send(buf).wait() {
Ok(tx) => tx,
Err(_) => break,
};
diff --git a/examples/echo-threads.rs b/examples/echo-threads.rs
index e2525c80..6ce8b156 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::{self, Executor};
+use futures::future::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(())
});
- future::blocking(srv).wait().unwrap();
+ srv.wait().unwrap();
}
fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) {
@@ -88,5 +88,5 @@ fn worker(rx: mpsc::UnboundedReceiver<TcpStream>) {
Ok(())
});
- future::blocking(done).wait().unwrap();
+ done.wait().unwrap();
}
diff --git a/examples/echo-udp.rs b/examples/echo-udp.rs
index 2ce43bc0..f7e2bf09 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, Future, Poll};
+use futures::{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
- future::blocking(Server {
+ 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 54a28ff7..558f3a68 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::{self, Executor};
+use futures::future::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.
- future::blocking(done).wait().unwrap();
+ done.wait().unwrap();
}
diff --git a/examples/hello.rs b/examples/hello.rs
index d9e46d17..5ceb431b 100644
--- a/examples/hello.rs
+++ b/examples/hello.rs
@@ -19,7 +19,6 @@ extern crate tokio_io;
use std::env;
use std::net::SocketAddr;
-use futures::future;
use futures::prelude::*;
use tokio::net::TcpListener;
@@ -41,5 +40,5 @@ fn main() {
Ok(())
});
- future::blocking(server).wait().unwrap();
+ server.wait().unwrap();
}
diff --git a/examples/hello_world.rs b/examples/hello_world.rs
index 5cac1259..fee06607 100644
--- a/examples/hello_world.rs
+++ b/examples/hello_world.rs
@@ -18,9 +18,10 @@ extern crate tokio;
extern crate tokio_io;
extern crate futures;
+use tokio::executor::current_thread;
use tokio::net::TcpListener;
use tokio_io::io;
-use futures::{current_thread, Future, Stream};
+use futures::{Future, Stream};
pub fn main() {
let addr = "127.0.0.1:6142".parse().unwrap();
diff --git a/examples/proxy.rs b/examples/proxy.rs
index f73dd30d..131fa41b 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::{self, Executor};
+use futures::future::{Executor};
use futures_cpupool::CpuPool;
use tokio::net::{TcpListener, TcpStream};
use tokio_io::{AsyncRead, AsyncWrite};
@@ -92,7 +92,8 @@ fn main() {
Ok(())
});
- future::blocking(done).wait().unwrap();
+
+ 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 3fa5f5ed..21456ada 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::{self, Executor};
+use futures::future::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(())
});
- future::blocking(server).wait().unwrap();
+ server.wait().unwrap();
}
fn write(socket: TcpStream) -> IoFuture<()> {
diff --git a/examples/tinydb.rs b/examples/tinydb.rs
index de750404..0a68a314 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::{self, Executor};
+use futures::future::Executor;
use futures_cpupool::CpuPool;
use tokio::net::TcpListener;
use tokio_io::AsyncRead;
@@ -160,7 +160,7 @@ fn main() {
Ok(())
});
- future::blocking(done).wait().unwrap();
+ done.wait().unwrap();
}
impl Request {
diff --git a/examples/tinyhttp.rs b/examples/tinyhttp.rs
index b0106d63..2f982484 100644
--- a/examples/tinyhttp.rs
+++ b/examples/tinyhttp.rs
@@ -90,7 +90,7 @@ fn worker(rx: mpsc::UnboundedReceiver<net::TcpStream>) {
})).unwrap();
Ok(())
});
- future::blocking(done).wait().unwrap();
+ done.wait().unwrap();
}
/// "Server logic" is implemented in this function.
diff --git a/examples/udp-codec.rs b/examples/udp-codec.rs
index 5c11e9f3..c874ebd7 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::{self, Executor};
+use futures::future::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(future::blocking(a).wait());
+ drop(a.wait());
}