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

EventLoop: yield fibers internally [fixup #14996] #15215

Conversation

ysbaddaden
Copy link
Contributor

Refactors the internals of the epoll/kqueue event loop to yield the fiber(s) to be resumed instead of blindly calling Crystal::Scheduler.enqueue, so the #run method becomes the one place responsible to enqueue the fibers.

The current behavior doesn't change, the #run method still enqueues the fiber immediately, but it can now be changed in a single place.

For example the execution context shard monkey-patches an alternative #run method that collects and returns fibers to avoid parallel enqueues from an evloop run to interrupt the evloop run (:sob:).

Note that the #close method still directly enqueues waiting fibers one by one, for now.

The behavior doesn't change: it keeps enqueueing the fiber immediately,
but we can now change the behavior at a higher level and a single place,
or have an alternative method that could collect the fibers for example.

Note that `#close` keeps simply enqueueing waiting fibers one by one.
@straight-shoota straight-shoota added this to the 1.15.0 milestone Nov 22, 2024
@straight-shoota straight-shoota merged commit fe90f27 into crystal-lang:master Nov 23, 2024
68 of 69 checks passed
@ysbaddaden ysbaddaden deleted the feature/lifetime-evloop+run-yield-fiber branch November 23, 2024 13:01
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.

2 participants