Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch filesystem events on queue.yaml instead of polling every 3 secs #10

Open
jaywonchung opened this issue Feb 7, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@jaywonchung
Copy link
Owner

jaywonchung commented Feb 7, 2022

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.

@jaywonchung jaywonchung added the enhancement New feature or request label Feb 7, 2022
@NobodyXu
Copy link
Contributor

NobodyXu commented Feb 7, 2022

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
Copy link
Contributor

NobodyXu commented Feb 7, 2022

Maybe we can wait until notify 5.0.0 is out.

@jaywonchung
Copy link
Owner Author

Notes for future reference:

  1. We edit queue.yaml ourselves, so we need to remove events generated by ourselves.
  2. 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 the delay we specify seems to be a trade-off between duplicate events and responsiveness. And there is not much advantage in using notify if we are to specify a delay larger than three seconds. Will have to look into this.

@jaywonchung
Copy link
Owner Author

Notify 5.0.0 is out. https://github.com/notify-rs/notify/blob/main/examples/async_monitor.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants