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

Function buf_ring_peek

freebsd/sys/buf_ring.h:284–302  ·  view source on GitHub ↗

* return a pointer to the first entry in the ring * without modifying it, or NULL if the ring is empty * race-prone if not protected by a lock */

Source from the content-addressed store, hash-verified

282 * race-prone if not protected by a lock
283 */
284static __inline void *
285buf_ring_peek(struct buf_ring *br)
286{
287
288#ifdef DEBUG_BUFRING
289 if ((br->br_lock != NULL) && !mtx_owned(br->br_lock))
290 panic("lock not held on single consumer dequeue");
291#endif
292 /*
293 * I believe it is safe to not have a memory barrier
294 * here because we control cons and tail is worst case
295 * a lagging indicator so we worst case we might
296 * return NULL immediately after a buffer has been enqueued
297 */
298 if (br->br_cons_head == br->br_prod_tail)
299 return (NULL);
300
301 return (br->br_ring[br->br_cons_head]);
302}
303
304static __inline void *
305buf_ring_peek_clear_sc(struct buf_ring *br)

Callers 1

drbr_dequeue_condFunction · 0.85

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected