Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_refcounted.h
Go to the documentation of this file.
1// Copyright 2018-2024, Collabora, Ltd.
2// Copyright 2023-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Reference-counted base for OpenXR state tracker objects.
7 * @ingroup oxr_main
8 */
9
10#pragma once
11
12#include "xrt/xrt_defines.h"
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
21{
22 struct xrt_reference base;
23 //! Destruction callback
24 void (*destroy)(struct oxr_refcounted *);
25};
26
27/*!
28 * Increase the reference count of @p orc.
29 */
30static inline void
32{
33 xrt_reference_inc(&orc->base);
34}
35
36/*!
37 * Decrease the reference count of @p orc, destroying it if it reaches 0.
38 */
39static inline void
41{
42 if (xrt_reference_dec_and_is_zero(&orc->base)) {
43 orc->destroy(orc);
44 }
45}
46
47
48#ifdef __cplusplus
49}
50#endif
static void oxr_refcounted_unref(struct oxr_refcounted *orc)
Decrease the reference count of orc, destroying it if it reaches 0.
Definition oxr_refcounted.h:40
static void oxr_refcounted_ref(struct oxr_refcounted *orc)
Increase the reference count of orc.
Definition oxr_refcounted.h:31
Definition oxr_refcounted.h:21
void(* destroy)(struct oxr_refcounted *)
Destruction callback.
Definition oxr_refcounted.h:24
A base class for reference counted objects.
Definition xrt_defines.h:99
Common defines and enums for XRT.