Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ref.h File Reference

Header file for reference counting. More...

#include <limits.h>
#include <stdbool.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/sys/__assert.h>

Go to the source code of this file.

Data Structures

struct  sys_refcount
 Reference counter. More...
struct  sys_ref
 Reference of an object. More...

Macros

#define SYS_REFCOUNT_INITIALIZER   { .value = ATOMIC_INIT(1) }
 Static initializer for a sys_refcount.
#define SYS_REF_INITIALIZER   { .refcount = SYS_REFCOUNT_INITIALIZER }
 Static initializer for a Reference counting.

Typedefs

typedef void(* sys_ref_release_t) (struct sys_ref *const ref)
 Release handler called once the last reference is dropped.

Functions

static void sys_refcount_init (struct sys_refcount *const rc)
 Initialize a reference counter to one.
static void sys_refcount_inc (struct sys_refcount *const rc)
 Increment a reference counter.
static bool sys_refcount_dec (struct sys_refcount *const rc)
 Decrement a reference counter.
static void sys_ref_init (struct sys_ref *const ref)
 Initialize a reference to one.
static void sys_ref_get (struct sys_ref *const ref)
 Increase reference of an object.
static bool sys_ref_put (struct sys_ref *const ref, const sys_ref_release_t release)
 Decrease reference of an object.

Detailed Description

Header file for reference counting.