Clarify ConstSharedPtr achieves zero-copy - #7064
Open
MShields1986 wants to merge 2 commits into
Open
Conversation
MShields1986
marked this pull request as ready for review
August 13, 2026 10:31
ottojo
reviewed
Aug 19, 2026
Re-add the plain const T & callback type to the list of subscriber signatures that do not achieve zero-copy, addressing reviewer feedback that this case was dropped from the previous clarification. Co-Authored-By: MShields1986 <matthew.shields@dexory.com>
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.
Description
The existing note on subscriber callback types incorrectly implied that no
shared_ptrvariant could achieve zero-copy, grouping mutableshared_ptr<T>andConstSharedPtrtogether.This is misleading:
const std::shared_ptr<const T> &(ConstSharedPtr) uses immutable shared ownership and delivers zero-copy to multiple intra-process subscribers simultaneously, making it the correct pattern for one-to-many composition.Changes:
shared_ptrsentence in the two-node pipeline section to distinguishConstSharedPtr(zero-copy capable) from mutableshared_ptr<T>(not zero-copy)ConstSharedPtrcallbacks avoid the fan-out copy penalty thatUniquePtrincurs in one-to-many graphsA more detailed write up with tests and findings is available here
Did you use Generative AI?
No
Additional Information
The correction to the
shared_ptrnote is a factual fix as the previous wording could lead readers to incorrectly avoidConstSharedPtrin one-to-many scenarios where it is the appropriate tool.