Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions watch_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package changes
/*
#cgo LDFLAGS: -framework CoreServices
#include <CoreServices/CoreServices.h>
#include <dispatch/dispatch.h>
FSEventStreamRef fswatch_new(
FSEventStreamContext*,
CFMutableArrayRef,
Expand All @@ -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"

Expand Down Expand Up @@ -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) {
Expand Down