-
Notifications
You must be signed in to change notification settings - Fork 34
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
SHM mutation #328
SHM mutation #328
Conversation
yellowhatter
commented
Dec 17, 2024
- mutable access to SHM example
- added necessary mutable accessors here and there
- added necessary mutable accessors here and there
#if defined(ZENOHCXX_ZENOHC) | ||
/// @brief The payload of this error. | ||
/// @return error payload. | ||
Bytes& get_payload() { |
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.
today there is no way to get mutable ReplyErr or Sample from reply, so this method is useless as it is.
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.
Then we should add this. SHM buffer may reside literally everywhere where ZBytes is
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.
That is the problem. We can not add these methods, because this would allow user to apply std::move to mutable Sample or ReplyError which would lead to their destruction. Since on zenoh-c level calling destructors is only possible on owned objects and sample/error are stored as loaned inside reply this would lead to UB.
So it is ok to merge this pr as is, but adding mutable access to sample/reply_err from Reply would require first resolving eclipse-zenoh/zenoh-c#718.
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.
Made mutable access to sample/reply_err from Reply private for a while.
@@ -433,14 +433,14 @@ class Session : public Owned<::z_owned_session_t> { | |||
SubscriberOptions&& options = SubscriberOptions::create_default(), | |||
ZResult* err = nullptr) const { | |||
static_assert( | |||
std::is_invocable_r<void, C, const Sample&>::value, | |||
std::is_invocable_r<void, C, Sample&>::value, |
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.
Similar fixes need to be done for every subscriber/queryable and get function :(
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.
done
@milyin I think, this PR really requires eclipse-zenoh/zenoh-c#718 to be resolved first. |
Conflicts: include/zenoh/api/ext/querying_subscriber.hxx