Watch filesystem events on `queue.yaml` instead of polling every 3 secs
jaywonchung opened this issue · 4 comments
jaywonchung commented
Currently, when queue.yaml
is empty, the scheduling loop just sleeps for three seconds and re-checks if there's any new commands. This is less responsive and it's basically polling.
Crates like notify
does filesystem watching, but it's not async. Especially, since its watcher takes std::sync::mpsc::{Sender, Receiver}
in its constructor and those are !Sync
.
NobodyXu commented
It seems like notify 5.0.0-pre.13 finally fixed this and allow users to provide a callback instead of a std::sync::mpsc::Sender
.
NobodyXu commented
Maybe we can wait until notify 5.0.0 is out.
jaywonchung commented
Notes for future reference:
- We edit
queue.yaml
ourselves, so we need to remove events generated by ourselves. - From the docs:
If you use a delay of more than 30 seconds, you can avoid receiving repetitions of previous events on macOS.
. So basically thedelay
we specify seems to be a trade-off between duplicate events and responsiveness. And there is not much advantage in usingnotify
if we are to specify a delay larger than three seconds. Will have to look into this.
jaywonchung commented
Notify 5.0.0 is out. https://github.com/notify-rs/notify/blob/main/examples/async_monitor.rs