xrt: Add xrt_reference struct

This commit is contained in:
Jakob Bornecrantz 2019-08-22 14:10:58 +01:00
parent 6774a7e1b3
commit 7f3651775b

View file

@ -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