Repository navigation
feat: added link_timeout and demo - #31
Open
matthewtolman wants to merge 1 commit into
Open
matthewtolman wants to merge 1 commit into
matthewtolman wants to merge 1 commit into
Conversation
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.
What Changed
Added wrapper for
io_uring_prep_link_timeoutwhich allows adding timeouts to I/O operations (e.g. read).I/O Uring will dispatch two events for a link timeout, one for the original I/O operation (e.g. read) with
-ETIMEDOUTwhen there's a timeout, and another for the timeout itself with code-ETIMEon a timeout.If there isn't a timeout, then two events are still emitted, one for the original I/O operation (e.g. read) with the normal return value, and another for the timeout itself with code
-ECANCELLED.To prevent confusion around doing two
co_awaitor managing two events for a timeout event, I opted to set the timeout to have an empty callback. Since it's using an empty callback and not a coroutine, there is no need to keep the return object "in scope", so I don't return anything. That said, I'm open to feedback on changing the API.I also added a demo on how to use it. The demo adapts the echo server demo and adds a timeout.
Usage: