diff options
Diffstat (limited to 'docs/ref/api/util/nng_id_map.md')
| -rw-r--r-- | docs/ref/api/util/nng_id_map.md | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/ref/api/util/nng_id_map.md b/docs/ref/api/util/nng_id_map.md index 016c60e4..1a516e44 100644 --- a/docs/ref/api/util/nng_id_map.md +++ b/docs/ref/api/util/nng_id_map.md @@ -45,9 +45,12 @@ Given a sufficiently large range, this is unlikely to be a concern.}} > These functions are _not_ thread-safe. > Callers should use a [mutex][mutex] or similar approach when thread-safety is needed. +The {{i:`nng_id_map_free`}} function deallocates one of these tables, and should be called +when it is no longer neeeded. + ### Initialization -An initial table is allocated with `nng_id_map_alloc`, which takes the lowest legal identifier in _lo_, +An initial table is allocated with {{i:`nng_id_map_alloc`}}, which takes the lowest legal identifier in _lo_, and the largest legal identifier in _hi_. The new table is returned in _map_p_, and should be used as the _map_ argument to the rest of these functions. @@ -58,27 +61,27 @@ then both _lo_ and _hi_ must be specified with the exact values desired. themselves be larger than this.}} The _flags_ argument is a bit mask of flags for the table. -If `NNG_MAP_RANDOM` is specified, then the starting point for allocations is randomized, but subsequent allocations will then be monotonically increasing. +If {{i:`NNG_MAP_RANDOM`}} is specified, then the starting point for allocations is randomized, but subsequent allocations will then be monotonically increasing. This is useful to reduce the odds of different instances of an application using the same identifiers at the same time. ### Accessors -The `nng_id_get` function returns the value previously stored with the given identifier. +The {{i:`nng_id_get`}} function returns the value previously stored with the given identifier. If no value is currently associated with the identifer, it returns `NULL`. -The `nng_id_set` function sets the value with the associated identifier. +The {{i:`nng_id_set`}} function sets the value with the associated identifier. This can be used to replace a previously allocated identifier. If the identifier was not previously allocated, then it is allocated as part of the call. This function does not necessarily honor the identifier range limits set for the map when it was allocated. -The `nng_id_alloc` function allocates a new identifier from the range for the map, and associates it with +The {{:`nng_id_alloc`}} function allocates a new identifier from the range for the map, and associates it with the supplied _value_. -The `nng_id_remove` function removes the identifier and its associated value from the table. +The {{:`nng_id_remove`}} function removes the identifier and its associated value from the table. ### Iteration -The `nng_id_visit` function is used to iterate over all items in the table. +The {{i:`nng_id_visit`}} function is used to iterate over all items in the table. The caller starts the iteration by setting the _cursor_ to 0 before calling it. For each call, the associated key and value of the next item will be returned in _id_p_, and _value_p_ and the _cursor_ will be updated. |
