Lines Matching refs:rc

61 refcount_create(refcount_t *rc)
63 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL);
64 list_create(&rc->rc_list, sizeof (reference_t),
66 list_create(&rc->rc_removed, sizeof (reference_t),
68 rc->rc_count = 0;
69 rc->rc_removed_count = 0;
73 refcount_destroy_many(refcount_t *rc, uint64_t number)
77 ASSERT(rc->rc_count == number);
78 while (ref = list_head(&rc->rc_list)) {
79 list_remove(&rc->rc_list, ref);
82 list_destroy(&rc->rc_list);
84 while (ref = list_head(&rc->rc_removed)) {
85 list_remove(&rc->rc_removed, ref);
89 list_destroy(&rc->rc_removed);
90 mutex_destroy(&rc->rc_mtx);
94 refcount_destroy(refcount_t *rc)
96 refcount_destroy_many(rc, 0);
100 refcount_is_zero(refcount_t *rc)
102 ASSERT(rc->rc_count >= 0);
103 return (rc->rc_count == 0);
107 refcount_count(refcount_t *rc)
109 ASSERT(rc->rc_count >= 0);
110 return (rc->rc_count);
114 refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
124 mutex_enter(&rc->rc_mtx);
125 ASSERT(rc->rc_count >= 0);
127 list_insert_head(&rc->rc_list, ref);
128 rc->rc_count += number;
129 count = rc->rc_count;
130 mutex_exit(&rc->rc_mtx);
136 refcount_add(refcount_t *rc, void *holder)
138 return (refcount_add_many(rc, 1, holder));
142 refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
147 mutex_enter(&rc->rc_mtx);
148 ASSERT(rc->rc_count >= number);
151 rc->rc_count -= number;
152 count = rc->rc_count;
153 mutex_exit(&rc->rc_mtx);
157 for (ref = list_head(&rc->rc_list); ref;
158 ref = list_next(&rc->rc_list, ref)) {
160 list_remove(&rc->rc_list, ref);
165 list_insert_head(&rc->rc_removed, ref);
166 rc->rc_removed_count++;
167 if (rc->rc_removed_count >= reference_history) {
168 ref = list_tail(&rc->rc_removed);
169 list_remove(&rc->rc_removed, ref);
173 rc->rc_removed_count--;
178 rc->rc_count -= number;
179 count = rc->rc_count;
180 mutex_exit(&rc->rc_mtx);
185 (u_longlong_t)(uintptr_t)rc);
190 refcount_remove(refcount_t *rc, void *holder)
192 return (refcount_remove_many(rc, 1, holder));