Repository navigation
feat(stream): stream_channel::publish_external — alias caller storage (Phase 2 PR3) - #517
Merged
Merged
Conversation
… Phase 2 PR3) Adds a producer path that publishes a frame ALIASING caller-owned storage via a supplied std::shared_ptr<void> keepalive, with NO pool slab — the prerequisite for the zero-copy pycvc producer (PR4), where a numpy ndarray's buffer is borrowed instead of copied into a slab. - publish_external(data, size, pts, keepalive): builds a frame borrowing `data` (keepalive co-owns it for the frame's life), stamps the next seq from the SAME counter as the pool path (seq monotonic across both), and fans out to every subscriber. The lease-based publish() is unchanged; the shared snapshot+deliver fan-out is factored into a private fan_out() helper used by both. - Thread-safe for a single producer thread (deliver() is atomic/bounded-queue safe; the subscriber snapshot is taken under subs_mu_ then delivered off-lock). The caller must treat `data` as immutable after publishing. Tests (stream_test): zero-copy alias (frame->data == caller buffer, pool untouched), seq interleaving across pool+external publishes, and keepalive released exactly when the last subscriber frame drops. 20/20 pass, valgrind clean.
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.
Adds a
stream_channelproducer path that publishes a frame aliasing caller-owned storage via a suppliedstd::shared_ptr<void>keepalive, with no pool slab. This is the hard prerequisite for the zero-copy pycvc producer (PR4): a numpy ndarray's buffer is borrowed, not copied into a slab.publish_external(data, size, pts, keepalive)builds a frame borrowingdata(keepalive co-owns it for the frame's life), stamps the next seq from the same counter as the pool path (seq monotonic across both producer paths), and fans out to every subscriber. The lease-basedpublish()is unchanged; the snapshot-under-lock + deliver-off-lock fan-out is factored into a privatefan_out()shared by both.deliver()is atomic/bounded-queue safe; subscribers snapshotted undersubs_mu_, delivered off-lock). Caller treatsdataas immutable after publishing.Tests: zero-copy alias (
frame->data== caller buffer, pool untouched), seq interleaving across pool+external publishes, keepalive released exactly when the last subscriber frame drops. 20/20 pass, valgrind clean. Purecvc::stream, no GL/Python/hardware.Independent of PR1/PR2 (disjoint files); unblocks PR4. Addresses the plan's risk #3 (the previously-undesigned external-producer contract): seq stamping shared with the pool, fan-out thread-safety, immutability.