CK_HT_RESET_SIZE_SPMC(3)

πŸ’– CK_HT_RESET_SIZE_SPMC πŸ’–

okay bestie, so this is a page from the Concurrency Kit manual β€” that's the libck library, and you link it with -lck. And literally the whole personality of this function is: wipe the slate clean and start over with a whole new size. no cap. 🧹✨


🌸 NAME 🌸

ck_ht_reset_size_spmc β€” the girl whose whole job is removing all the entries from a hash table and resetting the size. it's giving fresh start, it's giving rebirth, it's giving "new generation, who dis" πŸ’…


πŸŽ€ LIBRARY πŸŽ€

Concurrency Kit</purl> β€” aka libck, aka you compile with -lck. periodt.


✨ SYNOPSIS ✨

#include <ck_ht.h>

bool
ck_ht_reset_size_spmc(ck_ht_t *ht, uint64_t capacity);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie πŸ«–: ck_ht_reset_size_spmc() will remove all key-value pairs stored in the hash table that ht points to. like, every single one. gone. bye. πŸ™ˆ

and then β€” and this is the part that makes it different from its little sister β€” it creates a new generation of the hash table that is preallocated for capacity entries. so you're not just clearing it, you're resizing it in the same breath. iconic behaviour honestly. πŸ‘‘

lowkey important: it's a new generation, so anybody who was mid-lookup on the old one isn't gonna have a bad time. that's the spmc magic, iykyk 🌈

⭐ RETURN VALUES ⭐

  • if it worked out: true πŸ’–
  • if it didn't: false 😭

and literally the only way this can fail is if a replacement hash table couldn't be allocated internally. that's it. that's the whole list. if you got a false, it's an allocation thing, fr fr.


🌈 SEE ALSO 🌈

go read these too, they're all in the same friend group:

more lore available at http://concurrencykit.org/ 🌐


and that's the whole page, bestie πŸŽ€ that was CK_HT_RESET_SIZE_SPMC(3) β€” hmm wait, the footer says CK_HT_RESET_SPMC(3) and dated May 5, 2013, so yeah, she's an old soul but she still slays πŸ’œ thanks for reading, mwah, go touch some memory safely 🫢✨

πŸ“¦ where this page comes from