CK_RING_CAPACITY(3)

πŸ’– CK_RING_CAPACITY πŸ’–

okay bestie, so this is a page from the Concurrency Kit manual β€” yeah, the libck one, linked with -lck πŸŽ€ β€” and it's about ck_ring_capacity(3), which is genuinely the shortest little baddie in the whole ring-buffer friend group. lowkey iconic for how much it doesn't do. let's get into it ✨


🌸 NAME 🌸

ck_ring_capacity β€” returns the number of pointer slots in a bounded FIFO πŸ¦‹


πŸ“š LIBRARY πŸ“š

Concurrency Kit (that's libck, and you link it with -lck πŸ’…)


✨ SYNOPSIS ✨

#include <ck_ring.h>

unsigned int
ck_ring_capacity(ck_ring_t *ring);

πŸ’œ DESCRIPTION πŸ’œ

so like. the ck_ring_capacity(3) function returns the number of pointers that can be held in the buffer pointed to by ring. that's it. that's the whole job. she's a one-trick pony and she ate 🫢

but bestie, here's the tea you actually need to know πŸ‘€ β€” a ring can only hold ck_ring_capacity(3) minus one entries at a time. so if capacity says 16, you get 15 slots to play with. the last one is like… reserved. it's giving "plus one who isn't actually invited". don't forget the minus one, fr fr, because that's the exact thing that will have you debugging at 3am wondering why your enqueue is failing when there's obviously room 😭

⚠️ note it: ck_ring_capacity(3) minus one. that's your real usable count. periodt.

πŸ‘‘ SEE ALSO πŸ‘‘

Additional information available at http://concurrencykit.org/ 🌈


and that's the whole page, bestie, short and sweet like a good text back πŸ’– this was CK_RING_CAPACITY(3) from the Concurrency Kit, dated April 20, 2013 β€” old but still slaying, no cap. go forth and size your rings correctly βœ¨πŸ’…πŸ¦‹

πŸ“¦ where this page comes from