Make the Basic Event Loop example show the flow of control - #208
Merged
Conversation
Signed-off-by: yukik8 <andres8.yuuki@gmail.com>
yukik8
marked this pull request as ready for review
August 5, 2026 06:30
Member
|
Thanks for your suggestion, I made some minor refinement to make the output more concise, but overall this is a big improvement. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I read the Basic Event Loop example for the first time, I couldn't tell what it was demonstrating: the final output is identical to what blocking IO would produce, and the most important fact — that
io_waitsuspends the reader without blocking the program — is not visible anywhere in the output.This PR tries to make the flow of control visible:
[main]/[reader]/[writer]labels show which fiber each line comes from.[main]lines appearing while the reader is waiting — an ordering that would be impossible with blocking IO.I verified the example runs unchanged on Ruby 3.4.10 (macOS arm64) and produces exactly the output shown. (This also sidesteps the
Hash#inspectformat issue addressed in #207, since the example no longer prints a Hash.)Open question: I'm genuinely unsure about the trade-off — this version is much longer than the original 12 lines. Would you prefer:
Happy to rework it in any direction.
Types of Changes
Contribution