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

Fix starvation demo app in tuning guide #3881

Merged
merged 1 commit into from Nov 3, 2023

Conversation

armanbilge
Copy link
Member

@armanbilge armanbilge commented Oct 23, 2023

The demo actually wasn't starving because the fiber remained on the blocking thread it was shunted to for the preceding IO.println.

Further reading: https://typelevel.org/cats-effect/docs/faq#why-is-my-io-running-on-a-blocking-thread

h/t @felher

Comment on lines -32 to +35
IO.println(s"running #$i") >> IO(Thread.sleep(10000))
IO {
println(s"running #$i")
Thread.sleep(10000)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could insert an IO.cede in-between the two IOs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving out IO.cede keeps the example simpler for the broader public.

@armanbilge armanbilge merged commit 4fe0952 into series/3.5.x Nov 3, 2023
30 of 34 checks passed
@armanbilge armanbilge deleted the doc/fix-starve-thyself branch November 3, 2023 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants