-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove refcounting from reply/sample. #440
Conversation
Alternative solution after discussion with @sashacmc and @DenisBiryukov91: Make the allocated fields (payload, attachments...) refcounted and make the containers (reply, sample) copyable rather than refcounted. To avoid doubling interfaces. |
2508f63
to
0032525
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized, that query likely should stay ref counted, because zenoh allows to make copies of queries and send multiple replies through them. The query is considered to be finalized when the last copy is dropped.
Oudated.
_For Zenoh-C compatibility issue, we have a single
z_loaned_sample_t
type which corresponds both to a sample received by a sub and the sample contained in a reply.This type is refcounted as required for potential out-of-context usage by a subscriber. As replies are themselves refcounted that create a double refcount which is slightly wasteful memory-wise in a Query/reply scenario.
This PR attemps to offer a way to avoid this double refcounting by storing the reply sample without refcounting, provide a zenoh pico api to interact with it, while a call to the Zenoh-C api will still generate the recounted sample._