From 86d3455f8b59879141477f799d972d0703eff13a Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 7 Nov 2024 11:22:48 +0100 Subject: [PATCH] Add documentation and update comments --- docs/api.rst | 26 +++++++++++++++++++++++++ examples/unix/c11/z_sub_liveliness.c | 6 +----- include/zenoh-pico/api/liveliness.h | 18 ++++++++--------- include/zenoh-pico/collections/intmap.h | 2 +- src/api/api.c | 2 +- src/collections/intmap.c | 1 + 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index b76f7a040..a6c4a2dd2 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -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 ====== diff --git a/examples/unix/c11/z_sub_liveliness.c b/examples/unix/c11/z_sub_liveliness.c index 0fe79aaf0..18a6e7384 100644 --- a/examples/unix/c11/z_sub_liveliness.c +++ b/examples/unix/c11/z_sub_liveliness.c @@ -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) { @@ -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); diff --git a/include/zenoh-pico/api/liveliness.h b/include/zenoh-pico/api/liveliness.h index 15c859fa6..18301458c 100644 --- a/include/zenoh-pico/api/liveliness.h +++ b/include/zenoh-pico/api/liveliness.h @@ -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); @@ -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. @@ -84,14 +84,14 @@ 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); @@ -99,8 +99,8 @@ z_result_t z_liveliness_subscriber_options_default(z_liveliness_subscriber_optio * 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. @@ -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); diff --git a/include/zenoh-pico/collections/intmap.h b/include/zenoh-pico/collections/intmap.h index 8e414e548..98ea17379 100644 --- a/include/zenoh-pico/collections/intmap.h +++ b/include/zenoh-pico/collections/intmap.h @@ -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 diff --git a/src/api/api.c b/src/api/api.c index 4d20a71df..4e3d2d8d4 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -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, diff --git a/src/collections/intmap.c b/src/collections/intmap.c index 5035cb74d..0d7eac9ad 100644 --- a/src/collections/intmap.c +++ b/src/collections/intmap.c @@ -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];