Skip to content

Commit

Permalink
avoid infinite loop in ctrl-c supressing example
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Nov 27, 2020
1 parent 399b8c4 commit f3212c4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tokio/src/signal/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ unsafe extern "system" fn handler(ty: DWORD) -> BOOL {
/// let mut stream = ctrl_c()?;
///
/// // Print whenever a CTRL-C event is received.
/// loop {
/// for countdown in (0..3).rev() {
/// stream.recv().await;
/// println!("got signal CTRL-C");
/// println!("got CTRL-C. {} more to exit", countdown);
/// }
///
/// Ok(())
/// }
/// ```
pub fn ctrl_c() -> io::Result<CtrlC> {
Expand Down Expand Up @@ -184,10 +186,12 @@ impl CtrlC {
/// let mut stream = ctrl_c()?;
///
/// // Print whenever a CTRL-C event is received.
/// loop {
/// for countdown in (0..3).rev() {
/// stream.recv().await;
/// println!("got signal CTRL-C");
/// println!("got CTRL-C. {} more to exit", countdown);
/// }
///
/// Ok(())
/// }
/// ```
pub async fn recv(&mut self) -> Option<()> {
Expand Down

0 comments on commit f3212c4

Please sign in to comment.