()
| 129 | } |
| 130 | |
| 131 | func (w *Watcher) Close() { |
| 132 | w.mu.Lock() |
| 133 | if w.closed { |
| 134 | w.mu.Unlock() |
| 135 | return |
| 136 | } |
| 137 | w.closed = true |
| 138 | close(w.stopCh) |
| 139 | for ch := range w.subs { |
| 140 | delete(w.subs, ch) |
| 141 | close(ch) |
| 142 | } |
| 143 | w.mu.Unlock() |
| 144 | if w.fs != nil { |
| 145 | _ = w.fs.Close() |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | func (w *Watcher) loop() { |
| 150 | // A disabled (no-op) watcher has no fsnotify handle — just block until close. |