Skip to content

Commit

Permalink
Fix the timer thread never exits and can not deconstruct the pipe in …
Browse files Browse the repository at this point in the history
…poll. (tokio-rs#591)
  • Loading branch information
carllerche authored Apr 26, 2017
1 parent 2a00e2f commit 61bf9c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ struct Inner {
wakeup_thread: thread::JoinHandle<()>,
}

impl Drop for Inner {
fn drop(&mut self) {
// 1. Set wakeup state to TERMINATE_THREAD (https://github.com/carllerche/mio/blob/master/src/timer.rs#L451)
self.wakeup_state.store(TERMINATE_THREAD, Ordering::Release);
// 2. Wake him up
self.wakeup_thread.thread().unpark();
}
}

#[derive(Copy, Clone, Debug)]
struct WheelEntry {
next_tick: Tick,
Expand Down

0 comments on commit 61bf9c9

Please sign in to comment.