Repository navigation
feat(nx-sys-net): wake a blocked wait from another thread - #165
Merged
Merged
Conversation
A wait borrows the selector for its duration, so work handed to an event loop from another thread waits it out. With no pipe on this platform, the channel that ends a wait is a pair of loopback sockets. - Add `Waker`, opened against a `Selector` and holding the sending end of a datagram channel; the receiving end goes into the selector, so a caller never sees it and cannot forget to drain it - Put the channel first in every set `select` sends, drain it before reporting, and report the wake under the token it was opened with, so a selector with a channel blocks even with nothing registered - Refuse a second waker on one selector rather than replacing the channel, which would leave the first sending into a socket nothing waits on - Treat a full channel as a wake delivered: the datagram already queued returns the wait, so `wake` fails only when the send was refused for another reason - Cover the channel on hardware with a blocked poll a wake ends, and a drained channel that stops reporting itself ready Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
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.
A wait borrows the selector for its duration, so work handed to an event loop from another thread waits it out. With no pipe on this platform, the channel that ends a wait is a pair of loopback sockets.
Waker, opened against aSelectorand holding the sending end of a datagram channel; the receiving end goes into the selector, so a caller never sees it and cannot forget to drain itselectsends, drain it before reporting, and report the wake under the token it was opened with, so a selector with a channel blocks even with nothing registeredwakefails only when the send was refused for another reason