Non-blocking foreign IO operations on file descriptors#456
Open
Rewbert wants to merge 9 commits intoaugustss:masterfrom
Open
Non-blocking foreign IO operations on file descriptors#456Rewbert wants to merge 9 commits intoaugustss:masterfrom
Rewbert wants to merge 9 commits intoaugustss:masterfrom
Conversation
…y, instead passing a callback for what to do with the awake-able thread
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.
This PR adds support for non-blocking IO operations. GHC has an IO manager that (to my understanding) makes sure that
Here I've modified the code so that a simpler machinery can be slotted in via the
MHS_IO_POLLconfiguration. With this configuration enabled we addthread_io_waitint fdandint eventsand operations on them.
As we discussed on Friday @augustss, I have tried to lift the thread and queue-specific operations out of the polling code. Since we don't know how many events might be ready, we pass in a callback to
io_pollthat schedules a ready thread if any exist. Please check whether you like this approach. Ifio_pollwere to return some structure showing what threads are ready, we would have to loop over it outside of the polling machinery. Perhaps that is fine, but it is not what I did here.I also followed your advice regarding the macos variant. I did this for Linux, but have no mac to try it on. I asked Gemini to propose an implementation for macos, and it dutifully obliged.
I have added a test that spawns a server in a separate thread, and then blocks on it. The main thread issues three heartbeats, showing that it is still runnable, before connecting to the web server. This test is run in CI and pass on both Linux and Macos.
I have written a little light-weight networking package that implements basic socket-based network communications. It works with this addition, and as soon as this (or anything like it) is merged, I will put it on hackage. It compiles and works with both GHC and MHS. (https://github.com/Rewbert/network-light/tree/main). I am already using this for some cool projects, as we've already discussed!
Please advise on any changes you might want.