Repository navigation
Add an in-process message queue primitive - #93
Merged
Merged
Conversation
A mutex-guarded bidirectional queue between the worklet (uv loop) and the host (native thread): bounded rings of owned byte messages, uv_async wakeup on the worklet end, a signal callback on the host end, and close-as-EOF. Standalone with a unit test; not yet wired into the IPC path.
Draining a full ring wakes the peer producer so it can retry a write that returned would_block, giving both ends real backpressure.
- Wake a consumer on open if the peer already queued data, so a message sent before the consumer opened is not lost (a startup hang otherwise). - Cap a write's copied span at INT_MAX so the returned byte count never overflows the int return or aliases a negative status. - Document that the open wakeup means re-check both readable and writable, and that destroy runs on the uv thread once the peer is quiesced.
bavulapati
marked this pull request as ready for review
July 3, 2026 14:06
kasperisager
previously approved these changes
Jul 3, 2026
kasperisager
left a comment
Contributor
There was a problem hiding this comment.
Looks good! We can make it lock-free later as an optimisation.
No caller, and code needing the async handle can reach it directly through the public struct.
kasperisager
approved these changes
Jul 3, 2026
Merged
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.
Part 1 of replacing bare-kit's pipe-based worklet<->host IPC with an in-process queue (context: #92).
Bare Kit is entirely in-process (worklets are threads), so pipes and sockets are the wrong tool and are the root of the EOF-on-exit and win32 problems tracked in #92. This adds the transport that will replace them: a small mutex-guarded bidirectional message queue between the worklet, which runs on a libuv loop, and the host, which is a plain native thread.
uv_async; the host end via a caller-provided signal callback, which is the only platform-specific concern.readreturns length 0); writes give real backpressure (would_block), and draining a full ring wakes the peer to retry.Standalone and unit-tested here; not yet wired into the IPC path. The transport swap (worklet.c + worklet.js + host
bare_ipc, deleting the pipeipc.cfiles) follows in a second PR.Opening as a draft to get eyes on the queue design before I build the rewiring on top of it.