mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
signal: Upgrade ctrl+c example into cargo run-able version with proper Cargo.toml
This commit is contained in:
committed by
Carl Lerche
parent
010c2223ca
commit
48eda3fe2f
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "ctrl-c"
|
||||
version = "0.1.0"
|
||||
authors = ["Jules Kerssemakers <[email protected]>"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.1.14"
|
||||
tokio-core = "0.1.7"
|
||||
tokio-signal = "0.1"
|
||||
@@ -0,0 +1,17 @@
|
||||
extern crate futures;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_signal;
|
||||
|
||||
use futures::stream::Stream;
|
||||
use tokio_core::reactor::Core;
|
||||
|
||||
fn main() {
|
||||
let mut core = Core::new().unwrap();
|
||||
let ctrlc = tokio_signal::ctrl_c(&core.handle());
|
||||
let stream = core.run(ctrlc).unwrap();
|
||||
|
||||
core.run(stream.for_each(|()| {
|
||||
println!("Ctrl-C received!");
|
||||
Ok(())
|
||||
})).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user