notify-rs / notify

🔭 Cross-platform filesystem notification library for Rust.
https://docs.rs/notify
2.76k stars 219 forks source link

[Feature Request]: provider a watch multiple files api to instead of multiple call `Watcher#watch` #653

Open underfin opened 4 days ago

underfin commented 4 days ago

System details

What you did (as detailed as you can)

The performance has more overhead if multiple call Watcher#watch, watching 158 files take 88 ms at my local. The overhead look like the FsEventWatcher#stop and FsEventWatcher#run is call multiple times. It could be improve like this.


fn watch_multiple(&mut self, path: Vec<&Path>, recursive_mode: RecursiveMode) -> Result<()> {
        self.stop();
        for path in path {
                   let result = self.append_path(path, recursive_mode);
       }
        // ignore return error: may be empty path list
        let _ = self.run();
        result
    }

The Watcher#unwatch API is also need to give similar API.

If here provide a API to do it, it could be nice. Thank you.

wanyt commented 2 days ago

+1