|
Monado OpenXR Runtime
|
A pair of hashets (name_store and loc_store) with an optional mutex so that both members can be removed atomically. More...
#include <oxr/actions/oxr_pair_hashset.h>

Public Member Functions | |
| XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult | oxr_pair_hashset_init (struct oxr_logger *log, struct oxr_pair_hashset *pair) |
| Initialize the pair: create both hashets and the mutex. | |
| XRT_NONNULL_ALL void | oxr_pair_hashset_fini (struct oxr_pair_hashset *pair) |
| Finalize the pair: destroy mutex and both hashets. | |
| XRT_NONNULL_ALL XRT_CHECK_RESULT int | oxr_pair_hashset_insert_str_c (struct oxr_pair_hashset *pair, const char *name_cstr, const char *loc_cstr, struct u_hashset_item **out_name_item, struct u_hashset_item **out_loc_item) |
| Insert a name/localized string pair into both hashets under lock. | |
| XRT_NONNULL_ALL void | oxr_pair_hashset_erase_and_free (struct oxr_pair_hashset *pair, struct u_hashset_item **name_item_ptr, struct u_hashset_item **loc_item_ptr) |
| Erase and free both items from the pair under lock, and set the pointed-to pointers to NULL. | |
| XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult | oxr_pair_hashset_has_name_and_loc (struct oxr_pair_hashset *pair, const char *name, const char *loc, bool *out_has_name, bool *out_has_loc) |
| Check both name and loc stores under a single lock (atomic). | |
Data Fields | |
| struct u_hashset * | name_store |
| struct u_hashset * | loc_store |
| struct os_mutex | mutex |
A pair of hashets (name_store and loc_store) with an optional mutex so that both members can be removed atomically.
| XRT_NONNULL_ALL void oxr_pair_hashset_erase_and_free | ( | struct oxr_pair_hashset * | pair, |
| struct u_hashset_item ** | name_item_ptr, | ||
| struct u_hashset_item ** | loc_item_ptr | ||
| ) |
Erase and free both items from the pair under lock, and set the pointed-to pointers to NULL.
Either pointer may be NULL to skip that side.
| pair | Pair to remove from |
| name_item_ptr | Pointer to name item pointer (erased, freed, set to NULL) |
| loc_item_ptr | Pointer to loc item pointer (erased, freed, set to NULL) |
| XRT_NONNULL_ALL void oxr_pair_hashset_fini | ( | struct oxr_pair_hashset * | pair | ) |
Finalize the pair: destroy mutex and both hashets.
| pair | Pair to finalize |
| XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult oxr_pair_hashset_has_name_and_loc | ( | struct oxr_pair_hashset * | pair, |
| const char * | name, | ||
| const char * | loc, | ||
| bool * | out_has_name, | ||
| bool * | out_has_loc | ||
| ) |
Check both name and loc stores under a single lock (atomic).
Writes true to out_has_name if the name is present, and to out_has_loc if the localized name is present.
| pair | Pair whose stores to search |
| name | Null-terminated name string |
| loc | Null-terminated localized string |
| out_has_name | Output: true if name is present (duplicate) |
| out_has_loc | Output: true if loc is present (duplicate) |
| XRT_NONNULL_ALL XRT_CHECK_RESULT XrResult oxr_pair_hashset_init | ( | struct oxr_logger * | log, |
| struct oxr_pair_hashset * | pair | ||
| ) |
Initialize the pair: create both hashets and the mutex.
| log | Logger for error reporting |
| pair | Pair to initialize |
References oxr_error().
| XRT_NONNULL_ALL XRT_CHECK_RESULT int oxr_pair_hashset_insert_str_c | ( | struct oxr_pair_hashset * | pair, |
| const char * | name_cstr, | ||
| const char * | loc_cstr, | ||
| struct u_hashset_item ** | out_name_item, | ||
| struct u_hashset_item ** | out_loc_item | ||
| ) |
Insert a name/localized string pair into both hashets under lock.
On success, out_name_item and out_loc_item are set to the inserted items.
| pair | Pair to insert into |
| name_cstr | Name string (null-terminated) |
| loc_cstr | Localized string (null-terminated) |
| out_name_item | Output for the name store item |
| out_loc_item | Output for the loc store item |