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

Don't use polling for WatchService #43

Open
jart opened this issue Jan 29, 2017 · 1 comment
Open

Don't use polling for WatchService #43

jart opened this issue Jan 29, 2017 · 1 comment
Labels
P4 type=enhancement Make an existing feature better

Comments

@jart
Copy link

jart commented Jan 29, 2017

Google policy forbids unit tests from calling sleep. If sleep is used, they have to be categorized as medium tests.

It would be nice if PollingWatchService was replaced with an implementation that uses mutex conditions, e.g. wait() and notify().

@cgdecker
Copy link
Member

cgdecker commented Mar 3, 2017

Yeah, it's a bit awkward... if we wanted to we could have the WatchService implementation just get notified immediately whenever an event occurs that it might want to know about, but that would introduce more overhead for each operation that would count as an event (particularly any write to any file). The other major consideration I had was that near-synchronous notification of events is not something you're likely to get on any real file system, so it didn't make sense to me to have an implementation that would give you significantly different behavior than you'd get in a real file system.

All that said... I don't believe sleep should be called anywhere. PollingWatchService uses a ScheduledExecutorService to schedule its polling at a fixed rate, and from what I can tell that should be making use of wait()/notify() under the hood via a Condition.

@cpovirk cpovirk added type=enhancement Make an existing feature better P4 labels Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

3 participants