rlib
Convenience library for useful things
Loading...
Searching...
No Matches
rref.h File Reference

Refcount base struct shared by every refcounted type in rlib. More...

Go to the source code of this file.

Data Structures

struct  RRef
 Refcount base struct. More...
 

Macros

#define r_ref_refcount(ref)   r_atomic_uint_load (&((RRef *)ref)->refcount)
 Snapshot of the current refcount (atomic load).
 
#define R_REF_STATIC_INIT(destroy)   { 0, 0, (RDestroyNotify)destroy }
 Static initialiser for an embedded RRef field.
 
#define r_ref_init(self, destroy)
 Initialise an RRef field to refcount 1 with destructor destroy.
 

Functions

rpointer r_ref_ref (rpointer ref)
 Increment the refcount and return the same pointer.
 
void r_ref_unref (rpointer ref)
 Decrement the refcount; runs the destructor when it reaches zero.
 
rpointer r_ref_weak_ref (rpointer ref, RFunc notify, rpointer data)
 Register a weak-reference callback that fires when ref is destroyed.
 
rboolean r_ref_weak_unref (rpointer ref, RFunc notify, rpointer data)
 Cancel a previously registered weak-reference callback.
 

Detailed Description

Refcount base struct shared by every refcounted type in rlib.