MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bqueue_dequeue

Function bqueue_dequeue

freebsd/contrib/openzfs/module/zfs/bqueue.c:129–146  ·  view source on GitHub ↗

* Take the first element off of q. If there are no elements on the queue, wait * until one is put there. Return the removed element. */

Source from the content-addressed store, hash-verified

127 * until one is put there. Return the removed element.
128 */
129void *
130bqueue_dequeue(bqueue_t *q)
131{
132 void *ret = NULL;
133 uint64_t item_size;
134 mutex_enter(&q->bq_lock);
135 while (q->bq_size == 0) {
136 cv_wait_sig(&q->bq_pop_cv, &q->bq_lock);
137 }
138 ret = list_remove_head(&q->bq_list);
139 ASSERT3P(ret, !=, NULL);
140 item_size = obj2node(q, ret)->bqn_size;
141 q->bq_size -= item_size;
142 if (q->bq_size <= q->bq_maxsize - (q->bq_maxsize / q->bq_fill_fraction))
143 cv_signal(&q->bq_add_cv);
144 mutex_exit(&q->bq_lock);
145 return (ret);
146}
147
148/*
149 * Returns true if the space used is 0.

Callers 8

receive_writer_threadFunction · 0.85
get_next_range_nofreeFunction · 0.85
send_merge_threadFunction · 0.85
send_reader_threadFunction · 0.85
dmu_send_implFunction · 0.85
get_next_redact_recordFunction · 0.85
perform_thread_mergeFunction · 0.85
perform_redactionFunction · 0.85

Calls 6

mutex_enterFunction · 0.85
obj2nodeFunction · 0.85
mutex_exitFunction · 0.85
cv_wait_sigFunction · 0.50
list_remove_headFunction · 0.50
cv_signalFunction · 0.50

Tested by

no test coverage detected