mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Add xrt_reference struct
This commit is contained in:
parent
6774a7e1b3
commit
7f3651775b
|
@ -16,6 +16,16 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
* A base class for reference counted objects.
|
||||
*
|
||||
* @ingroup xrt_iface
|
||||
*/
|
||||
struct xrt_reference
|
||||
{
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Which blend mode does the device support, used as both a bitfield and value.
|
||||
*
|
||||
|
@ -356,6 +366,26 @@ union xrt_output_value {
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Inline functions
|
||||
*
|
||||
*/
|
||||
|
||||
static inline bool
|
||||
xrt_reference_dec(struct xrt_reference *xref)
|
||||
{
|
||||
int count = xrt_atomic_dec_return(&xref->count);
|
||||
return count == 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
xrt_reference_inc(struct xrt_reference *xref)
|
||||
{
|
||||
xrt_atomic_inc_return(&xref->count);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue