Ejemplo n.º 1
0
// Stop listening to the event stream.
func (es *EventStream) Stop() {
	if es.stream != nil {
		C.FSEventStreamStop(es.stream)
		C.FSEventStreamInvalidate(es.stream)
		C.FSEventStreamRelease(es.stream)
		C.CFRunLoopStop(es.rlref)
	}
	es.stream = nil
}
Ejemplo n.º 2
0
// Stop stops underlying FSEventStream and unregisters it from global runloop.
func (s *stream) Stop() {
	if s.ref == nilstream {
		return
	}
	wg.Wait()
	C.FSEventStreamStop(s.ref)
	C.FSEventStreamInvalidate(s.ref)
	C.CFRunLoopWakeUp(runloop)
	s.ref = nilstream
}
Ejemplo n.º 3
0
// Stop listening to the event stream.
func (es *EventStream) Stop() {
	if es.stream != nil {
		C.FSEventStreamStop(es.stream)
		C.FSEventStreamInvalidate(es.stream)
		C.FSEventStreamRelease(es.stream)
		C.CFRunLoopStop(es.rlref)
		registry.Delete(es.registryID)
	}
	es.stream = nil
	es.registryID = 0
}
Ejemplo n.º 4
0
func (w *Watcher) removeWatch(path string) error {
	w.wmut.Lock()
	stream, found := w.watches[path]
	w.wmut.Unlock()

	if found {
		C.FSEventStreamStop(stream)
		C.FSEventStreamInvalidate(stream)
		C.FSEventStreamRelease(stream)
		w.wmut.Lock()
		delete(w.watches, path)
		w.wmut.Unlock()
	}

	return nil
}
Ejemplo n.º 5
0
// Start creates a FSEventStream for the given path and schedules it with
// global runloop. It's a nop if the stream was already started.
func (s *stream) Start() error {
	if s.ref != nilstream {
		return nil
	}
	wg.Wait()
	p := C.CFStringCreateWithCStringNoCopy(nil, C.CString(s.path), C.kCFStringEncodingUTF8, nil)
	path := C.CFArrayCreate(nil, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil)
	ref := C.FSEventStreamCreate(nil, (C.FSEventStreamCallback)(C.gostream),
		&s.ctx, path, C.FSEventStreamEventId(atomic.LoadUint64(&since)), latency, flags)
	if ref == nilstream {
		return errCreate
	}
	C.FSEventStreamScheduleWithRunLoop(ref, runloop, C.kCFRunLoopDefaultMode)
	if C.FSEventStreamStart(ref) == C.Boolean(0) {
		C.FSEventStreamInvalidate(ref)
		return errStart
	}
	C.CFRunLoopWakeUp(runloop)
	s.ref = ref
	return nil
}
Ejemplo n.º 6
0
// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html#jumpTo_15
func (s Stream) invalidate() {
	C.FSEventStreamInvalidate(s.cstream)
}