Typedefs | |
typedef struct __os_refcount_impl | os_refcount_t |
Functions | |
void | os_refcount_init (os_refcount_t *refcount, os_refcount_callback_f func, void *arg) |
void | os_refcount_destroy (os_refcount_t *refcount) |
void | os_refcount_get (os_refcount_t *refcount) |
void | os_refcount_put (os_refcount_t *refcount) |
A generic implementation is provided that is suitable for all platforms that support the spinlock API in <oska/spinlock.h> (see Spinlocks).
typedef struct __os_refcount_impl os_refcount_t |
A reference count object.
void os_refcount_destroy | ( | os_refcount_t * | refcount | ) |
Destroy a reference count object.
refcount | the reference count. |
References os_spinlock_destroy().
void os_refcount_get | ( | os_refcount_t * | refcount | ) |
Atomically increase the reference count by 1.
refcount | the reference count. |
References os_spinlock_lock_intsave(), and os_spinlock_unlock_intrestore().
void os_refcount_init | ( | os_refcount_t * | refcount, | |
os_refcount_callback_f | func, | |||
void * | arg | |||
) |
Initialize a reference count to 1.
Initialized reference counts must be destroyed by calling os_refcount_destroy().
refcount | the reference count. | |
func | the function which will be called when the reference count reaches 0. | |
arg | an argument to pass to func. |
References os_spinlock_init().
void os_refcount_put | ( | os_refcount_t * | refcount | ) |
Atomically decrease the reference count by 1.
The callback function passed to the call to os_refcount_init() is called if the count was decreased to zero.
refcount | the reference count. |
References os_spinlock_lock_intsave(), and os_spinlock_unlock_intrestore().