Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_pair_hashset Struct Reference

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>

Collaboration diagram for oxr_pair_hashset:

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_hashsetname_store
 
struct u_hashsetloc_store
 
struct os_mutex mutex
 

Detailed Description

A pair of hashets (name_store and loc_store) with an optional mutex so that both members can be removed atomically.

Member Function Documentation

◆ oxr_pair_hashset_erase_and_free()

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.

Parameters
pairPair to remove from
name_item_ptrPointer to name item pointer (erased, freed, set to NULL)
loc_item_ptrPointer to loc item pointer (erased, freed, set to NULL)

◆ oxr_pair_hashset_fini()

XRT_NONNULL_ALL void oxr_pair_hashset_fini ( struct oxr_pair_hashset pair)

Finalize the pair: destroy mutex and both hashets.

Parameters
pairPair to finalize

◆ oxr_pair_hashset_has_name_and_loc()

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.

Parameters
pairPair whose stores to search
nameNull-terminated name string
locNull-terminated localized string
out_has_nameOutput: true if name is present (duplicate)
out_has_locOutput: true if loc is present (duplicate)
Returns
XR_SUCCESS if the check completed successfully

◆ oxr_pair_hashset_init()

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.

Parameters
logLogger for error reporting
pairPair to initialize
Returns
XR_SUCCESS or XR_ERROR_RUNTIME_FAILURE

References oxr_error().

◆ oxr_pair_hashset_insert_str_c()

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.

Parameters
pairPair to insert into
name_cstrName string (null-terminated)
loc_cstrLocalized string (null-terminated)
out_name_itemOutput for the name store item
out_loc_itemOutput for the loc store item
Returns
0 on success, non-zero on failure

The documentation for this struct was generated from the following file: