Skip to content

Commit

Permalink
Don't try to stop the runloop until it's definitely running
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfairley authored and passcod committed Nov 22, 2017
1 parent 9956260 commit 0ce9169
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ struct StreamContextInfo {
recursive_info: HashMap<PathBuf, bool>,
}

extern "C" {
pub fn CFRunLoopIsWaiting(runloop: cf::CFRunLoopRef) -> bool;
}

impl FsEventWatcher {
#[inline]
fn is_running(&self) -> bool {
Expand All @@ -99,6 +103,11 @@ impl FsEventWatcher {
if let Some(runloop) = self.runloop {
unsafe {
let runloop = runloop as *mut libc::c_void;

while !CFRunLoopIsWaiting(runloop) {
thread::yield_now();
}

cf::CFRunLoopStop(runloop);
}
}
Expand Down

0 comments on commit 0ce9169

Please sign in to comment.