Monado OpenXR Runtime
u_limited_unique_id.h
Go to the documentation of this file.
1// Copyright 2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief A very simple generator to create process unique ids.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @ingroup aux_util
8 */
9
10
11#pragma once
12
13#include "xrt/xrt_defines.h"
14
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20
21/*!
22 * This function returns a unsigned 64 bit value that is guaranteed to be unique
23 * within the current running process, and not zero. There is of course the
24 * limit of running out of those ID once all values has been returned, but the
25 * value is 64 bit so that should not be a practical limit. The value is useful
26 * when needing to implement caching of a complex object, this lets us not use
27 * memory addresses as keys which may be reused by underlying alloc
28 * implementation and could lead to false hits.
29 *
30 * The current implementation is naive and is a simple monotonic counter.
31 *
32 * @ingroup aux_util
33 */
36
37
38#ifdef __cplusplus
39}
40#endif
xrt_limited_unique_id_t u_limited_unique_id_get(void)
This function returns a unsigned 64 bit value that is guaranteed to be unique within the current runn...
Definition: u_limited_unique_id.cpp:23
A limited unique id, it is only unique for the process it is in, so must not be used or synchronized ...
Definition: xrt_defines.h:79
Common defines and enums for XRT.