CK_HS_STAT(3)

πŸ’– CK_HS_STAT(3) πŸ’–

okay so bestie, this is the ck_hs_stat page from the Concurrency Kit β€” that's libck, you link it with -lck β€” and it's genuinely one of the cutest little calls in the whole library. it just... tells you stuff. about your hash set. it's giving ✨receipts✨. let's get into it.


✨ NAME ✨

ck_hs_stat β€” get hash set status πŸ’…

like, the vibe check for your hash set. the numbers. the tea. 🫢


πŸ“š LIBRARY πŸ“š

Concurrency Kit (libck, and you link it with -lck)


πŸŽ€ SYNOPSIS πŸŽ€

#include <ck_hs.h>

void
ck_hs_stat(ck_hs_t *hs, struct ck_hs_stat *st);

that's it. that's the whole signature. two pointers, no return, no drama. 🌸


πŸ¦‹ DESCRIPTION πŸ¦‹

so ck_hs_stat(3) goes and stores various hash set statistics into the object that st points at. you hand it your hash set (hs) and a stats struct (st) and it fills that struct all the way up. no cap. πŸ”₯

the ck_hs_stat structure is defined like this, exactly like this, character for character:

struct ck_hs_stat {
        unsigned long tombstones;   /* Current number of tombstones in hash set. */
        unsigned long n_entries;    /* Current number of keys in hash set. */
        unsigned int probe_maximum; /* Longest read-side probe sequence. */
};

let's break down the little trio because they each have main character energy:

  • tombstones β€” an unsigned long, and it's the current number of tombstones in the hash set. yes bestie, tombstones. deleted-but-not-forgotten slots. RIP πŸͺ¦
  • n_entries β€” an unsigned long, the current number of keys in the hash set. the actual population. the headcount. πŸ‘‘
  • probe_maximum β€” an unsigned int, and it's the longest read-side probe sequence. aka the worst-case amount of walking-around somebody had to do to find their stuff. the struggle was real. 😭

πŸ“ RETURN VALUES πŸ“

ck_hs_stat(3) has no return value. it's a void girlie. it does the thing and it doesn't report back, because the whole point is that the answer is in st. periodt. πŸ’…


πŸ’€ ERRORS πŸ’€

listen, this is the part where you actually pay attention:

behavior is undefined if hs is uninitialized. like, undefined undefined. don't do it. πŸ™ˆ
behavior is undefined if this function is called by a non-writer thread. it's a writer-thread-only situation, bestie. do not pull up with a reader thread. ⚠️

🌈 SEE ALSO 🌈

the whole friend group, go read them all:

more info is available at http://concurrencykit.org/ 🧚


and that's the whole page!! this one's from September 17, 2012 and it's filed under CK_HS_STAT(3) β€” yeah, 2012, she's an elder but she still ate πŸ’–βœ¨ go get those stats, bestie, iykyk πŸŽ€

πŸ“¦ where this page comes from