-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Refactor and add comments to IOCP #run_once
#14380
Refactor and add comments to IOCP #run_once
#14380
Conversation
unless next_event | ||
Crystal::System.print_error "Warning: No runnables in scheduler. Exiting program.\n" | ||
::exit | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, this cannot actually happen because min_by
instead of min_by?
is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought (non blocking): is that the job of the eventloop to decide to exit? As stated in the error message, this is a matter for the scheduler.
libevent merely returns an error (no events), and the case is expected in my implementation for RFC #2: the schedulers use it to decide to start spinning then park themselves for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is definitely not a final solution. But it's just a stop gap for some odd edge case. So far it has never happend because the branch couldn't be reached and you'd get a different error if the queue was empty.
I think this was introduced before we even had an actual event loop on Windows and things were much more brittle.
unless next_event | ||
Crystal::System.print_error "Warning: No runnables in scheduler. Exiting program.\n" | ||
::exit | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
While reading through this method 2 years after writing it, I found it hard to understand what its doing.
So this patch adds some comments to annotate the code.
And I also realized the control flow could be restructed to be more linear and easier to follow.
Thes code changes introduce no semantic difference, the just bring it to a slightly better readable form. The resulting LLVM IR is almost identical, just with a few branch lables swapped (as expected).