Skip to content

Commit

Permalink
Add documentation and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 7, 2024
1 parent cd3dca9 commit 86d3455
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 16 deletions.
26 changes: 26 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,32 @@ Functions
.. autocfunction:: serialization.h::ze_serialize_substr
Liveliness
========================
Types
-----
.. autoctype:: liveliness.h::z_liveliness_declaration_options_t
.. autoctype:: liveliness.h::z_liveliness_subscriber_options_t
.. autoctype:: liveliness.h::z_liveliness_get_options_t
Represents a Liveliness token entity.
See details at :ref:`owned_types_concept`
.. c:type:: z_owned_liveliness_token_t
.. c:type:: z_loaned_liveliness_token_t
.. c:type:: z_moved_liveliness_token_t
Functions
---------
.. autocfunction:: liveliness.h::z_liveliness_declaration_options_default
.. autocfunction:: liveliness.h::z_liveliness_declare_token
.. autocfunction:: liveliness.h::z_liveliness_undeclare_token
.. autocfunction:: liveliness.h::z_liveliness_subscriber_options_default
.. autocfunction:: liveliness.h::z_liveliness_declare_subscriber
.. autocfunction:: liveliness.h::z_liveliness_get
Others
======
Expand Down
6 changes: 1 addition & 5 deletions examples/unix/c11/z_sub_liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ int main(int argc, char **argv) {
const char *mode = "client";
char *clocator = NULL;
char *llocator = NULL;
int n = 0;

int opt;
while ((opt = getopt(argc, argv, "k:e:m:l:n:")) != -1) {
Expand All @@ -59,11 +58,8 @@ int main(int argc, char **argv) {
case 'l':
llocator = optarg;
break;
case 'n':
n = atoi(optarg);
break;
case '?':
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l' || optopt == 'n') {
if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') {
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
} else {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
Expand Down
18 changes: 9 additions & 9 deletions include/zenoh-pico/api/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ _Z_OWNED_FUNCTIONS_DEF(liveliness_token)
/**************** Liveliness Token ****************/

/**
* The options for `z_liveliness_declare_token()`.
* The options for :c:func:`z_liveliness_declare_token()`.
*/
typedef struct z_liveliness_declaration_options_t {
uint8_t __dummy;
} z_liveliness_declaration_options_t;

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

Expand All @@ -57,10 +57,10 @@ z_result_t z_liveliness_declaration_options_default(z_liveliness_declaration_opt
* is achieved, and a DELETE sample if it's lost.
*
* Parameters:
* token: An uninitialized memory location where liveliness token will be constructed.
* zs: A Zenos session to declare the liveliness token.
* token: An uninitialized memory location where liveliness token will be constructed.
* keyexpr: A keyexpr to declare a liveliess token for.
* options: Liveliness token declaration properties.
* options: Liveliness token declaration options.
*
* Return:
* ``0`` if put operation is successful, ``negative value`` otherwise.
Expand All @@ -84,23 +84,23 @@ z_result_t z_liveliness_undeclare_token(z_moved_liveliness_token_t *token);

#if Z_FEATURE_SUBSCRIPTION == 1
/**
* The options for `z_liveliness_declare_subscriber()`
* The options for :c:func:`z_liveliness_declare_subscriber()`
*/
typedef struct z_liveliness_subscriber_options_t {
bool history;
} z_liveliness_subscriber_options_t;

/**
* Constucts default value for `z_liveliness_subscriber_options_t`.
* Constucts default value for :c:type:`z_liveliness_subscriber_options_t`.
*/
z_result_t z_liveliness_subscriber_options_default(z_liveliness_subscriber_options_t *options);

/**
* Declares a subscriber on liveliness tokens that intersect `keyexpr`.
*
* Parameters:
* token: An uninitialized memory location where subscriber will be constructed.
* zs: The Zenoh session.
* sub: An uninitialized memory location where subscriber will be constructed.
* keyexpr: The key expression to subscribe to.
* callback: The callback function that will be called each time a liveliness token status is changed.
* options: The options to be passed to the liveliness subscriber declaration.
Expand All @@ -117,14 +117,14 @@ z_result_t z_liveliness_declare_subscriber(const z_loaned_session_t *zs, z_owned

#if Z_FEATURE_QUERY == 1
/**
* The options for `z_liveliness_get()`
* The options for :c:func:`z_liveliness_get()`
*/
typedef struct z_liveliness_get_options_t {
uint32_t timeout_ms;
} z_liveliness_get_options_t;

/**
* Constructs default value `z_liveliness_get_options_t`.
* Constructs default value :c:type:`z_liveliness_get_options_t`.
*/
z_result_t z_liveliness_get_options_default(z_liveliness_get_options_t *options);

Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/collections/intmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {
#define _Z_DEFAULT_INT_MAP_CAPACITY 16

/**
* An entry of an hashmap with integer keys.
* An entry of a hashmap with integer keys.
*
* Members:
* size_t key: the hashed key of the value
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ z_result_t z_put(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr
opt.priority, opt.is_express, opt.timestamp, _z_bytes_from_owned_bytes(&opt.attachment->_this),
reliability);

// Trigger subscriptions
// Trigger subscriptions
_z_trigger_subscriptions_put(
_Z_RC_IN_VAL(zs), keyexpr_aliased, _z_bytes_from_owned_bytes(&payload->_this),
opt.encoding == NULL ? NULL : &opt.encoding->_this._val, opt.timestamp,
Expand Down
1 change: 1 addition & 0 deletions src/collections/intmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ bool _z_int_void_map_iterator_next(_z_int_void_map_iterator_t *iter) {
if (iter->_map->_vals == NULL) {
return false;
}

while (iter->_idx < iter->_map->_capacity) {
if (iter->_list_ptr == NULL) {
iter->_list_ptr = iter->_map->_vals[iter->_idx];
Expand Down

0 comments on commit 86d3455

Please sign in to comment.