21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
65#define r_ref_refcount(ref) r_atomic_uint_load (&((RRef *)ref)->refcount)
73#define R_REF_STATIC_INIT(destroy) { 0, 0, (RDestroyNotify)destroy }
75#define r_ref_init(self, destroy) R_STMT_START { \
76 r_atomic_uint_store (&((RRef *)self)->refcount, 1); \
77 r_atomic_ptr_store (&((RRef *)self)->weaklst, NULL); \
78 ((RRef *)self)->notify = (RDestroyNotify)destroy; \
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
rpointer r_ref_weak_ref(rpointer ref, RFunc notify, rpointer data)
Register a weak-reference callback that fires when ref is destroyed.
void r_ref_unref(rpointer ref)
Decrement the refcount; runs the destructor when it reaches zero.
rboolean r_ref_weak_unref(rpointer ref, RFunc notify, rpointer data)
Cancel a previously registered weak-reference callback.
rpointer r_ref_ref(rpointer ref)
Increment the refcount and return the same pointer.
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
void(* RFunc)(rpointer data, rpointer user)
Generic iteration callback over (data, user) pairs.
Definition rtypes.h:403
void(* RDestroyNotify)(rpointer ptr)
Destructor callback: free / release the value at ptr.
Definition rtypes.h:401
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
Atomic load / store / exchange / CAS / fetch-modify operations on integer, unsigned-integer and point...
Foundational type aliases used by every rlib header.
Refcount base struct.
Definition rref.h:58
raptr weaklst
Definition rref.h:60
rauint refcount
Definition rref.h:59
RDestroyNotify notify
Definition rref.h:61