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

take() blocks indefinitely #1

Open
hansenc opened this issue Oct 2, 2019 · 1 comment
Open

take() blocks indefinitely #1

hansenc opened this issue Oct 2, 2019 · 1 comment

Comments

@hansenc
Copy link

hansenc commented Oct 2, 2019

It looks like the core loop is using up a lot more CPU than it should due to a busy-wait, correct? Would it be better to sleep between iterations?

Btw, thanks for the blog post and WatchService example! Even though I don't know Kotlin, I found it easy to follow.

@hansenc
Copy link
Author

hansenc commented Oct 2, 2019

Sorry, I got it wrong in my last comment. Using take() blocks here, but doesn't that mean it will continue to block until a change happens? Meaning if no change happens it will block indefinitely? How will it be interrupted? (Note that poll() would be a solution, but we would want to avoid a busy-wait with that approach. Maybe a better approach would be to interrupt directly, but I'm not sure how that is accomplished with coroutines.)

@hansenc hansenc changed the title Busy-wait take() blocks indefinitely Oct 2, 2019
@hansenc hansenc changed the title take() blocks indefinitely take() blocks indefinitely Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant