diff options
author | Alex Crichton <alex@alexcrichton.com> | 2017-12-11 21:29:18 -0600 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2017-12-11 21:29:18 -0600 |
commit | a577bfc033b50c913c2241c432bcaeac3917145c (patch) | |
tree | 1151bc60d9f9373722d6bea9127b965a4db470bc /examples/echo-udp.rs | |
parent | 32f2750c2d99e82d64033c5865d2f4e029cb31ac (diff) |
Remove the `Reactor::run` method (#58)
This commit removes the `Reactor::run` method which has previously been used to
execute futures and turn the reactor at the same time. The tests/examples made
heavy usage of this method but they have now all temporarily moved to `wait()`
until the futures dependency is upgraded. In the meantime this'll allow us to
further trim down the `Reactor` APIs to their final state.
Diffstat (limited to 'examples/echo-udp.rs')
-rw-r--r-- | examples/echo-udp.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/examples/echo-udp.rs b/examples/echo-udp.rs index 0e163efe..0bcc3807 100644 --- a/examples/echo-udp.rs +++ b/examples/echo-udp.rs @@ -20,7 +20,7 @@ use std::net::SocketAddr; use futures::{Future, Poll}; use tokio::net::UdpSocket; -use tokio::reactor::Reactor; +use tokio::reactor::Handle; struct Server { socket: UdpSocket, @@ -54,18 +54,15 @@ fn main() { let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse::<SocketAddr>().unwrap(); - // Create the event loop that will drive this server, and also bind the - // socket we'll be listening to. - let mut l = Reactor::new().unwrap(); - let handle = l.handle(); + let handle = Handle::default(); let socket = UdpSocket::bind(&addr, &handle).unwrap(); println!("Listening on: {}", socket.local_addr().unwrap()); // Next we'll create a future to spawn (the one we defined above) and then - // we'll run the event loop by running the future. - l.run(Server { + // we'll block our current thread waiting on the result of the future + Server { socket: socket, buf: vec![0; 1024], to_send: None, - }).unwrap(); + }.wait().unwrap(); } |