Skip to content
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

Merged
merged 11 commits into from
Dec 18, 2024
Merged

SHM mutation #328

merged 11 commits into from
Dec 18, 2024

Conversation

yellowhatter
Copy link
Contributor

  • mutable access to SHM example
  • added necessary mutable accessors here and there

- added necessary mutable accessors here and there
@yellowhatter yellowhatter added enhancement New feature or request release Part of the next release api sync Synchronize API with other bindings labels Dec 17, 2024
@yellowhatter yellowhatter self-assigned this Dec 17, 2024
#if defined(ZENOHCXX_ZENOHC)
/// @brief The payload of this error.
/// @return error payload.
Bytes& get_payload() {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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 :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@DenisBiryukov91
Copy link
Contributor

@milyin I think, this PR really requires eclipse-zenoh/zenoh-c#718 to be resolved first.

@yellowhatter yellowhatter marked this pull request as ready for review December 18, 2024 09:53
@yellowhatter yellowhatter enabled auto-merge (squash) December 18, 2024 13:50
@yellowhatter yellowhatter merged commit 44a7728 into eclipse-zenoh:main Dec 18, 2024
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api sync Synchronize API with other bindings enhancement New feature or request release Part of the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants