PokerUnicorn
Loading...
Searching...
No Matches
Atomic Reference Counting

Atomic reference counting for thread-safe reference counting. More...

Data Structures

struct  pkrsrv_ref_counted_t
 Reference-counted object structure. More...
 

Macros

#define PKRSRV_REF_COUNTEDIFY()    pkrsrv_ref_counted_t ref_counted;
 Makes a structure reference-counted.
 

Functions

void pkrsrv_ref_counted_t::pkrsrv_ref_counted_init (pkrsrv_ref_counted_t *ref_counted, pkrsrv_ref_free_f_t free_f)
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
void pkrsrv_ref_counted_t::pkrsrv_ref_counted_use (pkrsrv_ref_counted_t *ref_counted)
 Increments the reference count of a reference-counted object.
 
void pkrsrv_ref_counted_t::pkrsrv_ref_counted_leave (void **obj_vp, pkrsrv_ref_counted_t *ref_counted)
 Decrements the reference count of a reference-counted object.
 

Detailed Description

Atomic reference counting for thread-safe reference counting.


Data Structure Documentation

◆ pkrsrv_ref_counted

struct pkrsrv_ref_counted

Reference-counted object structure.

+ Inheritance diagram for pkrsrv_ref_counted_t:

Public Member Functions

#define PKRSRV_REF_COUNTED_INIT(obj, free_f)    pkrsrv_ref_counted_init(&(obj->ref_counted), (pkrsrv_ref_free_f_t) free_f);
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
#define PKRSRV_REF_COUNTED_USE(obj)
 Increments the reference count of a reference-counted object.
 
#define PKRSRV_REF_COUNTED_LEAVE(obj)
 Decrements the reference count of a reference-counted object.
 

Data Fields

int count
 
pkrsrv_ref_free_f_t free_f
 
pthread_mutex_t mutex
 

Protected Member Functions

void pkrsrv_ref_counted_init (pkrsrv_ref_counted_t *ref_counted, pkrsrv_ref_free_f_t free_f)
 Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.
 
void pkrsrv_ref_counted_use (pkrsrv_ref_counted_t *ref_counted)
 Increments the reference count of a reference-counted object.
 
void pkrsrv_ref_counted_leave (void **obj_vp, pkrsrv_ref_counted_t *ref_counted)
 Decrements the reference count of a reference-counted object.
 

Field Documentation

◆ count

int pkrsrv_ref_counted_t::count

◆ free_f

pkrsrv_ref_free_f_t pkrsrv_ref_counted_t::free_f

◆ mutex

pthread_mutex_t pkrsrv_ref_counted_t::mutex

Macro Definition Documentation

◆ PKRSRV_REF_COUNTEDIFY

#define PKRSRV_REF_COUNTEDIFY ( )     pkrsrv_ref_counted_t ref_counted;

Makes a structure reference-counted.

Attention
Use in struct definition to make a structure reference-counted

Function Documentation

◆ pkrsrv_ref_counted_init()

void pkrsrv_ref_counted_init ( pkrsrv_ref_counted_t * ref_counted,
pkrsrv_ref_free_f_t free_f )
protected

Initializes a reference-counted object. Should be called in the constructor of the object after the dynamic allocation.

◆ pkrsrv_ref_counted_use()

void pkrsrv_ref_counted_use ( pkrsrv_ref_counted_t * ref_counted)
protected

Increments the reference count of a reference-counted object.

◆ pkrsrv_ref_counted_leave()

void pkrsrv_ref_counted_leave ( void ** obj_vp,
pkrsrv_ref_counted_t * ref_counted )
protected

Decrements the reference count of a reference-counted object.