howeyc/fsnotify

Single vs multiple instance(s) of watcher(s)

elgs opened this issue · 2 comments

elgs commented

If I have multiple directories to watch, the directories may be physically located across different disks, or partitions? Should I use only one instance of watcher, created by watcher, _ := fsnotify.NewWatcher(), or should I create separate watchers for each directory?

Thanks,
Elgs

elgs commented

I have only one instance of the watcher to watch multiple directories now, including the recursive sub directories. Looks like it works without any problem. By the way, currently I have moved my fsnotify related project from Mac to Linux (in Parallels). Everything seems to be perfect on Linux, however, the one on Mac is not usable now.

elgs commented

I finally chose multiple instances for the reason that if I use only one instance, anything happens in any watched directory will trigger the watcher. This itself is not a problem. However, the reality is that I share the same watcher in multiple goroutines, but I don't want all goroutines to be alerted if only one watched changes. So I finally decided to get each goroutine own its own watcher.