Refactor: simplify Crystal::Scheduler#17091
Draft
ysbaddaden wants to merge 6 commits into
Draft
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
There can also only be one event loop and stack pool. No need to associate them to the scheduler, and no need to associate the scheduler to the current thread (quite the opposite).
So we can enqueue fibers to the scheduler from other threads.
8c1eaca to
7f12e6c
Compare
Collaborator
Author
|
Allright, we used to not initialize the schedulers for interpreted code (sigh) and a nilable is always better than |
Sija
reviewed
Jun 23, 2026
Sija
reviewed
Jun 23, 2026
ysbaddaden
added a commit
to ysbaddaden/crystal
that referenced
this pull request
Jun 23, 2026
ysbaddaden
added a commit
to ysbaddaden/crystal
that referenced
this pull request
Jun 25, 2026
Until crystal-lang#17091 a mere fiber enqueue will instantiate a scheduler (and event loop) for the bare thread. It happens once, and the scheduler will never run, but it's pointless.
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.
A quick refactor to simplify
Crystal::Schedulerfor:without_mt. It allows safefiber.enqueuefrom any thread, which will help to simplify a couple cases on Windows where IOCP doesn't quite fit (e.g.ReadConsoleWfor reading from stdin andRegisterWaitSingleObjectto wait for processes).Follow up to #17001.