diff --git a/watch_darwin.go b/watch_darwin.go index ba124a6..9e1a444 100644 --- a/watch_darwin.go +++ b/watch_darwin.go @@ -7,6 +7,7 @@ package changes /* #cgo LDFLAGS: -framework CoreServices #include +#include FSEventStreamRef fswatch_new( FSEventStreamContext*, CFMutableArrayRef, @@ -16,6 +17,9 @@ FSEventStreamRef fswatch_new( static CFMutableArrayRef fswatch_make_mutable_array() { return CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); } +static dispatch_queue_t fswatch_dispatch_queue() { + return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); +} */ import "C" @@ -58,11 +62,8 @@ func startScanner(dir string) { stream := C.fswatch_new(&ctx, cpaths, now, C.CFTimeInterval(interval/time.Second), cflags) - go func() { - C.FSEventStreamScheduleWithRunLoop(stream, C.CFRunLoopGetCurrent(), C.kCFRunLoopCommonModes) - C.FSEventStreamStart(stream) - C.CFRunLoopRun() - }() + C.FSEventStreamSetDispatchQueue(stream, C.fswatch_dispatch_queue()) + C.FSEventStreamStart(stream) } func waitForNextScan(dir string) {