summaryrefslogtreecommitdiffstats
path: root/examples/udp-codec.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2017-10-25 10:54:54 -0700
committerCarl Lerche <me@carllerche.com>2017-11-01 07:28:49 -0700
commitc6f1ff13d249a42a5d0ae716dffca6a22cd1d7ca (patch)
tree7d5845668553eea08013cb75fdfbc4cb4f629255 /examples/udp-codec.rs
parent697851210c13e3df637a93af526cf6e41a217cfd (diff)
Remove executor from reactor.
In accordance with tokio-rs/tokio-rfcs#3, the executor functionality of Tokio is being removed and will be relocated into futures-rs as a "current thread" executor. This PR removes task execution from the code base. As a temporary mesure, all examples and tests are switched to using CpuPool. Depends on #19.
Diffstat (limited to 'examples/udp-codec.rs')
-rw-r--r--examples/udp-codec.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/udp-codec.rs b/examples/udp-codec.rs
index 4066060e..65a522ca 100644
--- a/examples/udp-codec.rs
+++ b/examples/udp-codec.rs
@@ -9,11 +9,14 @@
extern crate tokio;
extern crate env_logger;
extern crate futures;
+extern crate futures_cpupool;
use std::io;
use std::net::SocketAddr;
use futures::{Future, Stream, Sink};
+use futures::future::Executor;
+use futures_cpupool::CpuPool;
use tokio::net::{UdpSocket, UdpCodec};
use tokio::reactor::Core;
@@ -39,6 +42,8 @@ fn main() {
let mut core = Core::new().unwrap();
let handle = core.handle();
+ let pool = CpuPool::new(1);
+
let addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
// Bind both our sockets and then figure out what ports we got.
@@ -73,6 +78,6 @@ fn main() {
let b = b_sink.send_all(b_stream);
// Spawn the sender of pongs and then wait for our pinger to finish.
- handle.spawn(b.then(|_| Ok(())));
+ pool.execute(b.then(|_| Ok(()))).unwrap();
drop(core.run(a));
}