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

Subscriber callbacks now receive a refcounted z_sample #410

Merged
merged 12 commits into from
May 15, 2024

Conversation

jean-roland
Copy link
Contributor

Similarly to #327, this PR switch to refcounted z_sample for subscriber callbacks so they can be easily used out of the callback's context. Now it necessarily impacts the API a little, but this will be changed in a future PR anyway so considerations on this aspect should be limited.

This PR contains:

  • A code centralization refactor of z_sample and z_reply from multiple places to specific modules.
  • A switch to refcounted z_sample for subscriber callbacks, and z_loaned_sample for replies callbacks.
  • Added accessors functions for z_sample, similar to what we did for z_query
  • Subsequent update of tests and examples.

If you could review this @sashacmc.

Copy link
Member

@sashacmc sashacmc left a comment

Choose a reason for hiding this comment

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

In general LGTM (well, besides the fact that the interface will still have to be changed, but that’s my concern)
Only please revert z_reply_ok return type naming

}

void _z_sample_move(_z_sample_t *dst, _z_sample_t *src) {
dst->keyexpr._id = src->keyexpr._id; // FIXME: call the z_keyexpr_move
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should finally fix this FIXME?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function doesn't exist, I wasn't sure if it was the right PR to create those. Because I might as well do it for all of them.

@@ -45,7 +45,7 @@ void reply_dropper(void *ctx) {
void reply_handler(z_owned_reply_t *oreply, void *ctx) {
(void)(ctx);
if (z_reply_is_ok(oreply)) {
z_sample_t sample = z_reply_ok(oreply);
z_loaned_sample_t sample = z_reply_ok(oreply);
Copy link
Member

Choose a reason for hiding this comment

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

Please revert z_reply_ok result type renaming z_sample_t / z_loaned_sample_t
(z_reply_ok in the new API will return const z_loaned_sample_t *, I already did it and this renaming will only introduce additional conflicts.)

@OlivierHecart OlivierHecart merged commit 382e3ab into eclipse-zenoh:protocol_changes May 15, 2024
51 checks passed
@jean-roland jean-roland deleted the ft_sample_rc branch May 27, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants