-
Notifications
You must be signed in to change notification settings - Fork 58
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
take operation accepts mutable loaned reference for types which supports it #718
base: main
Are you sure you want to change the base?
Conversation
PR missing one of the required labels: {'bug', 'internal', 'breaking-change', 'enhancement', 'dependencies', 'documentation', 'new feature'} |
PR missing one of the required labels: {'dependencies', 'new feature', 'breaking-change', 'enhancement', 'bug', 'documentation', 'internal'} |
PR missing one of the required labels: {'breaking-change', 'bug', 'dependencies', 'new feature', 'enhancement', 'internal', 'documentation'} |
PR missing one of the required labels: {'enhancement', 'internal', 'new feature', 'breaking-change', 'bug', 'dependencies', 'documentation'} |
After quick discusion it was decided to reduce this update only for types actually used by callbacks |
Agreed with @DenisBiryukov91 opition that the real goal is to allow user to take |
Summary of latest discussion with @DenisBiryukov91 about the issue: The "take from loaned" functionality is necessary for C++ Explanation: C++ doesn't actually use "z_xxx_loaned_t*" types. Each C++ object is a wrapper over corresponding "owned" zenoh-c object. This works only for objects which conforms condition Internally in rust the The problem is in conversion in opposite direction: from loaned to moved. The example of problematic sequence of operations is:
The proposed solution: allow C++ to implement move constructor by taking important data from mutable loaned reference, keeping at the original place something "empty": dummy but valid. Thus the following operations should be defined:
The difference between "unspecified" and "gravestone" state is this: In short: new
|
This update adds
z_sample_take_loaned
,z_reply_take_loaned
,z_query_take_loaned
andz_hello_take_loaned
operations on correspondingz_loaned_sample_t*
,z_loaned_reply_t*
,z_loaned_hello_t*
, andz_loaned_query_t*
.This API this is made for callbacks, which accepts data as mutable loaned references. Now user can either access the object on place or take it with
z_xxx_take_loaned
to process later.Internally this update provides guaranty that for objects supporting
take_loaned
operations the reference toOption<...>
object is converted to mutablez_loaned_xxx*
pointer. I.e. the&Sample
in converted toconst z_loaned_sample*
and&mut Option<Sample>
- toz_loaned_sample_t*
.