Skip to content

feat(nx-sys-net): wake a blocked wait from another thread - #165

Merged
LNSD merged 1 commit into
mainfrom
lnsd/sys-net-waker
Aug 17, 2026
Merged

LNSD merged 1 commit into
mainfrom
lnsd/sys-net-waker

Conversation

@LNSD

@LNSD LNSD commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

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

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>
@LNSD
LNSD added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit a9055c1 Aug 17, 2026
4 checks passed
@LNSD
LNSD deleted the lnsd/sys-net-waker branch August 17, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant