t8  1.2.0
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
Macros | Typedefs | Functions
t8_refcount.h File Reference

We inherit the reference counting mechanism from libsc. More...

#include <t8.h>
#include <sc_refcount.h>

Go to the source code of this file.

Macros

#define t8_refcount_ref(rc)   sc_refcount_ref(rc)
 Increase the reference count by one. More...
 
#define t8_refcount_unref(rc)   sc_refcount_unref(rc)
 Decrease the reference count by one. More...
 
#define t8_refcount_is_active(rc)   sc_refcount_is_active(rc)
 Query wether a reference counter is has a positive value.
 
#define t8_refcount_is_last(rc)   sc_refcount_is_last(rc)
 Query wether a reference counter has value one.
 

Typedefs

typedef sc_refcount_t t8_refcount_t
 We can reuse the reference counter type from libsc.
 

Functions

void t8_refcount_init (t8_refcount_t *rc)
 Initialize a reference counter to 1. More...
 
t8_refcount_tt8_refcount_new (void)
 Create a new reference counter with count initialized to 1. More...
 
void t8_refcount_destroy (t8_refcount_t *rc)
 Destroy a reference counter that we allocated with t8_refcount_new. More...
 

Detailed Description

We inherit the reference counting mechanism from libsc.

The only customization is to pass the package id of the t8code. This file is compatible with sc_refcount_ref and sc_refcount_unref.

Macro Definition Documentation

◆ t8_refcount_ref

#define t8_refcount_ref (   rc)    sc_refcount_ref(rc)

Increase the reference count by one.

It is not necessary to duplicate this functionality as a function.

◆ t8_refcount_unref

#define t8_refcount_unref (   rc)    sc_refcount_unref(rc)

Decrease the reference count by one.

The count must be greater zero on input. If the reference count reaches zero, which is indicated by the return value, the counter may NOT be used furter with t8_refcount_ref or

See also
t8_refcount_unref. It IS legal to query it with t8_refcount_is_active and t8_refcount_is_last and to repurpose it later by calling t8_refcount_init. It is not necessary to duplicate this functionality as a function.
Parameters
[in]rcReference counter
Returns
true if and only if the refcount is 0 after the operation.

Function Documentation

◆ t8_refcount_destroy()

void t8_refcount_destroy ( t8_refcount_t rc)

Destroy a reference counter that we allocated with t8_refcount_new.

Its reference count must have decreased to zero.

Parameters
[in,out]rcAllocated, formerly valid reference counter.

◆ t8_refcount_init()

void t8_refcount_init ( t8_refcount_t rc)

Initialize a reference counter to 1.

It is legal if its status prior to this call is undefined.

Parameters
[out]rcThe reference counter is set to one by this call.

◆ t8_refcount_new()

t8_refcount_t* t8_refcount_new ( void  )

Create a new reference counter with count initialized to 1.

Equivalent to calling t8_refcount_init on a newly allocated refcount_t. It is mandatory to free this with t8_refcount_destroy.

Returns
An allocated reference counter whose count has been set to one.