Skip to content

Commit 7fd41b3

Browse files
Don't try to stop the runloop until it's definitely running
1 parent 80594cf commit 7fd41b3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/fsevent.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ struct StreamContextInfo {
8585
recursive_info: HashMap<PathBuf, bool>,
8686
}
8787

88+
extern "C" {
89+
pub fn CFRunLoopIsWaiting(runloop: cf::CFRunLoopRef) -> bool;
90+
}
91+
8892
impl FsEventWatcher {
8993
#[inline]
9094
fn is_running(&self) -> bool {
@@ -99,6 +103,11 @@ impl FsEventWatcher {
99103
if let Some(runloop) = self.runloop {
100104
unsafe {
101105
let runloop = runloop as *mut libc::c_void;
106+
107+
while !CFRunLoopIsWaiting(runloop) {
108+
thread::yield_now();
109+
}
110+
102111
cf::CFRunLoopStop(runloop);
103112
}
104113
}

0 commit comments

Comments
 (0)