示例#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
}
示例#2
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
}
示例#3
0
// Close closes a watcher instance
// It sends a message to the reader goroutine to quit and removes all watches
// associated with the kevent instance
func (w *Watcher) Close() error {
	w.mu.Lock()
	if w.isClosed {
		w.mu.Unlock()
		return nil
	}
	w.isClosed = true
	w.mu.Unlock()

	// Send "quit" message to the reader goroutine
	w.done <- true
	w.wmut.Lock() // I think fsnotify_bsd may have a very minor bug? It used w.pmut
	ws := w.watches
	w.wmut.Unlock()
	for path := range ws {
		w.removeWatch(path)
	}
	C.CFRunLoopStop(w.rlref)

	return nil
}
示例#4
0
// Releases all resources and closes the channel
// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/Reference/reference.html#jumpTo_16
func (s Stream) release() {
	C.FSEventStreamRelease(s.cstream)
	C.CFRunLoopStop(s.runloop)
}