Skip to content

Commit

Permalink
Fix review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 13, 2024
1 parent 91acb44 commit 345e02a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ Liveliness
========================
Types
-----
.. autoctype:: liveliness.h::z_liveliness_declaration_options_t
.. autoctype:: liveliness.h::z_liveliness_token_options_t_t
.. autoctype:: liveliness.h::z_liveliness_subscriber_options_t
.. autoctype:: liveliness.h::z_liveliness_get_options_t
Expand All @@ -1289,7 +1289,7 @@ See details at :ref:`owned_types_concept`
Functions
---------
.. autocfunction:: liveliness.h::z_liveliness_declaration_options_default
.. autocfunction:: liveliness.h::z_liveliness_token_options_t_default
.. autocfunction:: liveliness.h::z_liveliness_declare_token
.. autocfunction:: liveliness.h::z_liveliness_undeclare_token
.. autocfunction:: liveliness.h::z_liveliness_subscriber_options_default
Expand Down
11 changes: 5 additions & 6 deletions include/zenoh-pico/api/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ _Z_OWNED_FUNCTIONS_DEF(liveliness_token)
/**
* The options for :c:func:`z_liveliness_declare_token()`.
*/
typedef struct z_liveliness_declaration_options_t {
typedef struct z_liveliness_token_options_t_t {
uint8_t __dummy;
} z_liveliness_declaration_options_t;
} z_liveliness_token_options_t_t;

/**
* Constructs default value for :c:type:`z_liveliness_declaration_options_t`.
* Constructs default value for :c:type:`z_liveliness_token_options_t_t`.
*/
z_result_t z_liveliness_declaration_options_default(z_liveliness_declaration_options_t *options);
z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t_t *options);

/**
* Constructs and declares a liveliness token on the network.
Expand All @@ -66,8 +66,7 @@ z_result_t z_liveliness_declaration_options_default(z_liveliness_declaration_opt
* ``0`` if put operation is successful, ``negative value`` otherwise.
*/
z_result_t z_liveliness_declare_token(const z_loaned_session_t *zs, z_owned_liveliness_token_t *token,
const z_loaned_keyexpr_t *keyexpr,
const z_liveliness_declaration_options_t *options);
const z_loaned_keyexpr_t *keyexpr, const z_liveliness_token_options_t_t *options);

/**
* Undeclare a liveliness token, notifying subscribers of its destruction.
Expand Down
18 changes: 8 additions & 10 deletions src/api/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ void _z_liveliness_token_clear(_z_liveliness_token_t *token) {
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_liveliness_token_t, liveliness_token, _z_liveliness_token_check,
_z_liveliness_token_null, _z_liveliness_token_clear)

z_result_t z_liveliness_declaration_options_default(z_liveliness_declaration_options_t *options) {
z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t_t *options) {
options->__dummy = 0;
return _Z_RES_OK;
}

z_result_t z_liveliness_declare_token(const z_loaned_session_t *zs, z_owned_liveliness_token_t *token,
const z_loaned_keyexpr_t *keyexpr,
const z_liveliness_declaration_options_t *options) {
const z_liveliness_token_options_t_t *options) {
(void)options;

_z_keyexpr_t key = _z_update_keyexpr_to_declared(_Z_RC_IN_VAL(zs), *keyexpr);
Expand Down Expand Up @@ -96,18 +96,18 @@ z_result_t z_liveliness_declare_subscriber(const z_loaned_session_t *zs, z_owned
z_internal_closure_sample_null(&callback->_this);
sub->_val = int_sub;

if (!_z_subscriber_check(&sub->_val)) {
return _Z_ERR_SYSTEM_OUT_OF_MEMORY;
}

if (opt.history) {
z_result_t ret = _z_liveliness_subscription_trigger_history(_Z_RC_IN_VAL(zs), *keyexpr);
if (ret != _Z_RES_OK) {
return ret;
}
}

if (!_z_subscriber_check(&sub->_val)) {
return _Z_ERR_SYSTEM_OUT_OF_MEMORY;
} else {
return _Z_RES_OK;
}
return _Z_RES_OK;
}
#endif // Z_FEATURE_SUBSCRIPTION == 1

Expand All @@ -126,16 +126,14 @@ z_result_t z_liveliness_get(const z_loaned_session_t *zs, const z_loaned_keyexpr
void *ctx = callback->_this._val.context;
callback->_this._val.context = NULL;

_z_keyexpr_t key = _z_update_keyexpr_to_declared(_Z_RC_IN_VAL(zs), *keyexpr);

z_liveliness_get_options_t opt;
if (options == NULL) {
z_liveliness_get_options_default(&opt);
} else {
opt = *options;
}

ret = _z_liveliness_query(_Z_RC_IN_VAL(zs), key, callback->_this._val.call, callback->_this._val.drop, ctx,
ret = _z_liveliness_query(_Z_RC_IN_VAL(zs), *keyexpr, callback->_this._val.call, callback->_this._val.drop, ctx,
opt.timeout_ms);

z_internal_closure_reply_null(
Expand Down

0 comments on commit 345e02a

Please sign in to comment.