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

Add EventLoop#run(blocking) and EventLoop#interrupt #14568

Conversation

ysbaddaden
Copy link
Contributor

Implements a couple methods to run the event loop in non-blocking mode in addition to the blocking mode, plus the ability to interrupt a blocked thread. This adds the ability to:

  • quickly check the event loop for fibers to resume, without necessarily blocking;
  • interrupt a thread waiting on the event loop, allowing it to resume operation;

These features aren't needed right now, but that will change with RFC 0002.

Both the libevent and IOCP implementations have been manually tested.

The IOCP implementation hasn't been tested, yet.
src/crystal/system/win32/event_loop_iocp.cr Show resolved Hide resolved
src/io/overlapped.cr Outdated Show resolved Hide resolved
@ysbaddaden ysbaddaden marked this pull request as draft May 7, 2024 10:32
@crysbot
Copy link

crysbot commented May 7, 2024

This pull request has been mentioned on Crystal Forum. There might be relevant details there:

https://forum.crystal-lang.org/t/curious-about-the-eventloop-updates/6825/1

@straight-shoota straight-shoota changed the title Add EventLoop#run(blocking) and EventLoop#interrupt Add EventLoop#run(blocking) and EventLoop#interrupt May 7, 2024
@ysbaddaden ysbaddaden marked this pull request as ready for review May 16, 2024 12:18
@straight-shoota straight-shoota added this to the 1.13.0 milestone May 21, 2024
@straight-shoota straight-shoota merged commit 8817739 into crystal-lang:master May 22, 2024
60 of 61 checks passed
@ysbaddaden ysbaddaden deleted the feature/nonblocking-and-interruptible-event-loop branch May 22, 2024 12:21
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.

None yet

3 participants