Skip to content

Add Crystal::EventLoop#drain(&)#16522

Closed
ysbaddaden wants to merge 1 commit intocrystal-lang:masterfrom
ysbaddaden:feature/drain-event-loop
Closed

Add Crystal::EventLoop#drain(&)#16522
ysbaddaden wants to merge 1 commit intocrystal-lang:masterfrom
ysbaddaden:feature/drain-event-loop

Conversation

@ysbaddaden
Copy link
Collaborator

This is needed by the io_uring event loop that must drain a scheduler's local ring before it shutdown (e.g. when a context is resized down).

Extracted from #16264

# Must yield every runnable fiber.
#
# Optional.
def drain(& : Fiber ->) : Nil
Copy link
Member

Choose a reason for hiding this comment

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

thought: Since the implementation is optional and we really only need it for a single implementation, maybe we shouldn't add it to the generic interface? It seems silly to have this method on all event loop interfaces but it doesn't do anything.
As an alternative, we could implement it only for EventLoop::IOUring and check with @event_loop.responds_to?(:drain).

@ysbaddaden
Copy link
Collaborator Author

Yes, probably a better idea for starters.

@ysbaddaden ysbaddaden marked this pull request as draft December 19, 2025 11:13
@ysbaddaden
Copy link
Collaborator Author

Closing. Since it involved 2 distinct parts (EC vs EV) a formal API was interesting, but I'm not so sure about the name and expected behavior. The io_uring branch will simply patch support.

@ysbaddaden ysbaddaden closed this Dec 19, 2025
@github-project-automation github-project-automation bot moved this from Review to Done in Multi-threading Dec 19, 2025
@ysbaddaden ysbaddaden deleted the feature/drain-event-loop branch December 19, 2025 13:27
ysbaddaden added a commit to ysbaddaden/crystal that referenced this pull request Jan 12, 2026
ysbaddaden added a commit to ysbaddaden/crystal that referenced this pull request Jan 23, 2026
ysbaddaden added a commit to ysbaddaden/crystal that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants