Main index | Section 9 | Options |
#include <sys/param.h>
#include <sys/refcount.h>
The refcount_init() function is used to set the initial value of the counter to value. It is normally used when creating a reference-counted object.
The refcount_acquire() function is used to acquire a new reference. The caller is responsible for ensuring that it holds a valid reference while obtaining a new reference. For example, if an object is stored on a list and the list holds a reference on the object, then holding a lock that protects the list provides sufficient protection for acquiring a new reference.
The refcount_release() function is used to release an existing reference. The function returns true if the reference being released was the last reference; otherwise, it returns false.
Note that these routines do not provide any inter-CPU synchronization, data protection, or memory ordering guarantees except for managing the counter. The caller is responsible for any additional synchronization needed by consumers of any containing objects. In addition, the caller is also responsible for managing the life cycle of any containing objects including explicitly releasing any resources when the last reference is released.
REFCOUNT (9) | July 21, 2019 |
Main index | Section 9 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | … one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs. | ” |
— Robert Firth |